Showing results for 
Search instead for 
Did you mean: 

read every certain rows of an array

Dear all:
I have a question and couldn't figure out the solution. Hope someone can help me. I have a 2-D array and need to do 2 kinds of job.
First, give an integer number X and retrieve every Xth row to form a new array.
Second, give integer numbers Y and Z, check the number in the Yth column and retrieve the row only when this number is equal to Z to form a new array.
I wire the array into a for loop and put a case structure to execute the selection. I wire the selected row out the case when this condition is true, but I am lost for what to do when the condition is false. Or, my idea is totally wrong and I should use a different strategy to deal with the selection.
Hope someone can help me figure out the solution. Thanks a lot in advance.
0 Kudos
Message 1 of 9
It sounds like you're trying to check each row to see if it's one you want to extract. You don't need to do this, as you can use the "Quotient & Remainder" function to specify how many times to loop based on X:

Note: This is only for the first part of your question.

Message Edited by smercurio_fc on 05-14-2007 03:07 PM

Message 2 of 9
Now, to complete the answer, you can drive a for-loop with your 2D array and create the 2 arrays you want simultaneously. Basically you just need a shift register and in your case statement you use a Build Array to add to the array if the condition is true. Otherwise, you pass the array you're building out:

Message Edited by smercurio_fc on 05-14-2007 03:17 PM

Message 3 of 9
Thank you for your point! I think I got it. By the way, I notice that the number in your initial array is "empty". How did you do that? I used "zero" and am curious your way to set it. Anyway, thank you again.
0 Kudos
Message 4 of 9
In the Array subpalette there's an "Array Constant". Plop it down onto your diagram, and then drag the element type into it. For example, if you want an array of I32s, drag and drop an I32 constant into it. You can resize the index to set the dimensions.
0 Kudos
Message 5 of 9
To create an empty array to initialize a shift register that is already wired inside, just right-click the left tunnel and select "create constant" 🙂
Anyway, there is no need to built arrays in shift registers, so you don't need any empty arrays.
  1. For problem one, just get every Nth Row and autoindex at the output tunnel
  2. For problem two, slice out the desired row and find the indices of matching elements. Use the indices to grab the columns. There is no need to drag 2D the array through all procedures. 🙂

Here's a simple example for both (LabVIEW 8.0).

Message Edited by altenbach on 05-14-2007 04:21 PM

Download All
Message 6 of 9
Thank you for your advice! II can move on with your help. Thanks again.
0 Kudos
Message 7 of 9
As you can see, there's usually more than one way to solve the same problem.

Leave it to altenbach to always provide an alternate solution. Funny as to how it always seems to be related to solutions I provide. If I were a paranoid person I'd think he's following me around. Smiley Very Happy
0 Kudos
Message 8 of 9

@smercurio_fc wrote:
If I were a paranoid person I'd think he's following me around. Smiley Very Happy

It's not you. I follow everyone around...:)

 ......Booh! 😮

0 Kudos
Message 9 of 9