LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert 2D array into an existing 2D array

Is there an easy way to do this? Basically I'm pulling some 2d subset
out of a 2d array, doing some computations on it, and trying to ADD
(not replace) the new subset back into it's original spot in the 2d
array. I'm getting hung up b/c the "insert into array" doesn't seem
to want to let me pick x,y coordinates to place my new subset.

0 Kudos
Message 1 of 12
(4,498 Views)
Hi,

Here is a program that creates a 2d array of random numbers, and extracts out a 2d subset, and increments each number in the 2d subset by 1, and puts the subset back into the original array. You should be able to modify this code a little bit with the computation you would like to perform.

-Tim
Message 2 of 12
(4,491 Views)
Where is "the original spot" relative to the original array subset?

Message Edited by tedbeard on 08-24-2007 04:29 PM

0 Kudos
Message 3 of 12
(4,486 Views)
Hi,

The original spot is determined by the row and column index controls. Since there is now length wired, the subset goes all the way until the end of the row and the end of the column. If you wire in a constant for the length, the subset will only be the length long in the row or column direction.

-Tim
Message 4 of 12
(4,477 Views)
Sounded to me like the intent was to INSERT rather than REPLACE, retaining the original data. In that case, you can't specify both a row AND column since you can only operate on one dimension of the array at a time.

Message Edited by Bill@NGC on 08-24-2007 02:56 PM

Message 5 of 12
(4,475 Views)
I don't know who is giving out one-star ratings here, but Tim's example was quite reasonable given the initial question. Typically, the quality of the answer cannot be better than the quality of the question. 😉
 
You have a 2D array and take a subset, and want to add it to the same spot (your words). Tim's interpretation was much more obvious, especially since a resizing of arrays is always expensive.
 
Here's a graphical illustration.
 
 
Maybe it would help to show an image to explain exactly what you want to do. By making an image, you might even notice that there could be topological problems. 🙂

Message Edited by altenbach on 08-24-2007 03:32 PM

Message 6 of 12
(4,457 Views)

I gave him 1 star ratings because his replies answered neither question.

The OP asked how to insert a chunk back into the original spot. He didn't answer the question, instead explaining how to replace the original chunk.

Then I asked the OP where exactly the "original spot" was because the meaning of his phrase is ambiguous. Is it left, right, above, or below the original data? Where will the original data go? (Your post does a wondeful job of illustrating the confusion.) Timothy then misread my question, and he then wrote a reply explaining the index controls of the replace subset VI.

I am simply trying to help the OP solve his problem. Timothy's posts didn't seem to assist. Therefore, I rated them one star.

I mean no ill will.

 

Best wishes,

Ted

Message Edited by tedbeard on 08-24-2007 06:34 PM

Message Edited by tedbeard on 08-24-2007 06:35 PM

0 Kudos
Message 7 of 12
(4,447 Views)


@tedbeard wrote:

I gave him 1 star ratings because his replies answered neither question.


Yes, he did!

"...and trying to ADD (not replace) the new subset back into it's original spot.. " The subset is added to the existing values in the original spot, exactly as requested.

For some easy reading, have a look at the following current thread:
http://forums.ni.com/ni/board/message?board.id=130&message.id=3281&jump=true

You are not the original poster so you don't have the right to judge the quality of an answer, especially in a grey areas where you don't even know what the OP really wants. Throwing low ratings around like that is very counterproductive to the forum, because people will be afraid to answer in fear of low ratings. If somebody makes a serious effort to answer and even create an example (!), that should be encouraged by all means.

A post either deserves a top rating, or no rating. We don't need any negativity here. Anything else (spam, completely offtopic) should be removed by the moderator.

See also: http://forums.ni.com/ni/board/message?board.id=130&message.id=3321#M3321

 

0 Kudos
Message 8 of 12
(4,435 Views)


@altenbach wrote:


@tedbeard wrote:

I gave him 1 star ratings because his replies answered neither question.


Yes, he did!

"...and trying to ADD (not replace) the new subset back into it's original spot.. " The subset is added to the existing values in the original spot, exactly as requested.

For some easy reading, have a look at the following current thread:
http://forums.ni.com/ni/board/message?board.id=130&message.id=3281&jump=true

You are not the original poster so you don't have the right to judge the quality of an answer, especially in a grey areas where you don't even know what the OP really wants. Throwing low ratings around like that is very counterproductive to the forum, because people will be afraid to answer in fear of low ratings. If somebody makes a serious effort to answer and even create an example (!), that should be encouraged by all means.

A post either deserves a top rating, or no rating. We don't need any negativity here. Anything else (spam, completely offtopic) should be removed by the moderator.

See also: http://forums.ni.com/ni/board/message?board.id=130&message.id=3321#M3321


The OP specifically said not replace. Timothy's VI is named replacearray.vi. Inside the vi, it uses the Replace Array Subset VI.
 
Sorry if I've acted offensively. Can I inquire why members are given the option to rate posts if we're not supposed to "judge the quality of an answer" and if we're not allowed to give any ratings except the top rating? I think it's terrible if people are afraid of helping other people because of a star that shows up on a webpage.
 
I now see that this a contested and sensitive issue. I was unaware that 1-4 stars were bad. Is there anyway to undo ratings?

Message Edited by tedbeard on 08-24-2007 07:43 PM

0 Kudos
Message 9 of 12
(4,423 Views)
Hey guys, I wandered over here from google groups. I had no idea that what gets posted there, gets posted here, too. I seemed to have unwittingly caused dissension in the ranks, and I apologize about that.  ANYWAY.  The top right pic in altenbach's diagram best explains what I want to do. In particular, I want to add the elts of the subarray onto the existing elts in the larger array.  Completely wiping out the existing elts of that section and replacing them with the elts of the subarry is not what I was going for.

The only way I could see to do this is to initialize a 256x256 array of zeros, and use "replace subset" to insert the the kernel of new values, then add the 256x256 array of zeros+kernel to the original 256x256 array. You can see how I don't want to do that as I would have to initialize a 256x256 array of zeros 65,536 times as I wish to operate on every elt in the original array.  And, the arrays will not always be as small as 256x256.   If you guys can give me any further advice, I'd appreciate it. Thanks!
0 Kudos
Message 10 of 12
(4,396 Views)