LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

replace array column by row definition

Hello to all,
 
I have an initialized 2D 10x10 array with all values being zero.
 
How can I insert a 1D array into any of the 10 columns starting at any specified row?
 
The 1D array will never exceed the 10x10 parameter
 
Thanks N Advance!
 
FredFred
0 Kudos
Message 1 of 6
(3,162 Views)

The only way that I though to do this was by using a for loop and inserting the values into the array one by one...

Is there a simpler way to do this?

 

Thanks!

0 Kudos
Message 2 of 6
(3,145 Views)

You have to use a loop, however, you can still simplify your code quite a bit.

Use autoindexing! (This will eliminate the array size node and the index node inside the loop). 🙂

See attached, LabVIEW 7.1.

Message 3 of 6
(3,140 Views)

When I first saw this question I thought you had to use a loop too, but my boss and I talked about it for a minute and he came up with a way to do it without a loop, but instead with two Replace Array Subset functions.  Check it out:

I've also attached the VI, saved in 8.0 format.

-D

Message Edited by Darren on 03-20-200603:16 PM

Download All
Message 4 of 6
(3,137 Views)
Thanks
 
I've always had a problem with auto indexing, but now realize its value. Thanks a bunch
0 Kudos
Message 5 of 6
(3,129 Views)

Darren,

Cute! I was always a sucker for "loop free" algorithms! 🙂

In this case, the loop version is probably a bit more efficient and the code size is actually ~20% smaller (2K vs 2.4K).

For a 10x10 array it does not really matter. For huge arrays, only a benchmark will tell. 😉

0 Kudos
Message 6 of 6
(3,118 Views)