From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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

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
(2,621 Views)

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 LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,613 Views)

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
(2,603 Views)
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
(2,597 Views)
Solution
Accepted by topic author gats
This should do the same thing without all of the extra steps.
Message 5 of 6
(2,590 Views)
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
(2,580 Views)