LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to replace subset of nd array with 1d array at i,j

Solved!
Go to solution
Highlighted

Hi,

 

I am trying to replace a range of values in a multidimensional array  starting at cell i,j with both greater than 0, ie a square inside the nD array. The new values that will be replacing the old ones come from a 1D array. However, when I provide both indexes to replace array subset block I am getting a bad wire... I assume that this is due to the fact that labview doesn't know which direction to replace the data?? Is there any solution to that? I am attaching an example vi of what I am trying to do.

 

Many thanks.

 

Download All
0 Kudos
Message 1 of 6
(1,228 Views)
Highlighted

Hi gats,

 

trivial way:

index out the column or row where you want to replace values. In the resulting 1d array you can replace several values. Then you replace the whole row (or column) in the 2d array... Or replace just scalar values in the 2d array.

 

Edited:

Maybe you can use the "inplace" structure of newer LabView versions for this process, but I can't test this right now...

Message Edited by GerdW on 05-13-2009 09:23 PM
Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 6
(1,220 Views)
Highlighted

gats,

 

You also seem to have a major misconception about arrays. You say you want to replace a square but you are using a 1D array. A 'square' has two dimensions. If you really want to replace a square, you need to use a 2D array.

0 Kudos
Message 3 of 6
(1,210 Views)
Highlighted
Hi guys thanks for the quick replies... Apologies for the square..., more accurate a rectacular of dimensions 1xn or a line area within the array. In any case I think I managed to resolve it by creating a dummy 2d array from the 1d array. The vi attached... If someone has a more elegant solution please input...
0 Kudos
Message 4 of 6
(1,204 Views)
Highlighted
Solution
Accepted by topic author gats
This should do the same thing without all of the extra steps.
Message 5 of 6
(1,197 Views)
Highlighted
Yup, this sounds good... You are "forcing" the array as a one column array resolving the problem of which way to replace at x,y...  Make sense. Thanks :).
0 Kudos
Message 6 of 6
(1,187 Views)