From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Manipulating subarrays with a for loop?

Solved!
Go to solution

Hi all,

 

Below is a picture of what I am trying to do: Basically, I want to select the A (3x3) subarray, manipulate the corresponding data, then

select the B (2x2) subarray, manipulate the corresponding data, then finally select the C (4x4) subarray, and manipulate its corresponding

data. In my real problem, I have more than just A, B, C. I could have any number of variables.

 

I do have a 1D array as well, shown below, which I use to do some kind of matching with my 2D array so I can select the appropriate subarray.

 

Please see the attached VI, and see if my approach makes sense. To be concrete, the final output of my VI should be a 2D array containig

A, B, C and for each variable, I want the total sum of all numbers corresponding to that subarray.

For example for A, I want 1+2+2+2+1+5. My actual data manipulation would be more complicated, but if I can figure out this simple case,

the actual case will follow.

 

I just don't know where to store each subbarray in my for loop and WHEN to do my data manipulation, should it be inside the inner for loop, outside, where? See the attached VI.

 

Thanks in advance.

 

 

 

 

 

2d_array_manip.JPG

 

0 Kudos
Message 1 of 6
(2,574 Views)

Sorry, I don't have LV 2011.  Can you down-convert to 8.X.  Thanks.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 2 of 6
(2,568 Views)

See attached. Thanks

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

I'm not sure if I understood what you're asking for, but I think the attached example will do what you want.

0 Kudos
Message 4 of 6
(2,532 Views)
Solution
Accepted by topic author murchak

I think you need some initialization and to wire through the false case.

 

Note that the output is a three dimensional array.  Because the pages cannot be different sizes, the "A" and "B" pages contain some blank elements. If not match is found fo an element in 1D array, an entire page will be blank. To see this replace "B" in 1D array with "D".

 

To do your summation a String to number conversion followed by Array Sum works well.

 

Lynn

Message 5 of 6
(2,531 Views)

Thank you very much Johnsold!

 

It worked exactly like I wanted to.

 

I really appreciate your help, and all those other volunteers who put their time into helping others. This is just great.

0 Kudos
Message 6 of 6
(2,515 Views)