LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help me for build a array as follows

Solved!
Go to solution

Hi. I need build a array, with the number 10 in all positions of array. For example, if array is of size 10x10, the number 10 must appear in the 100 positions of array. But I need that the number  go storing in array  as follows: That store the number 10 in all row 1 of left to right, in row 2 of right to left and so on. I attached my VI, but i have a problem, the program make well the sequence but the number 10 no storing  in some positions, this positions is inthe extrems of some row,i think that i need to maintain the number of column for two cicles, buy i don't know very....Help me.!!...Thanks!! 

0 Kudos
Message 1 of 7
(2,412 Views)

Is this you want to achieve?

 

2D Array-10 FP.png

 

2D Array-10.png

 

Good Luck.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 7
(2,402 Views)

You said you want your array to be 10x 10, but you initialized it to only 9 x 9.

 

Pay attention to where you increment your index.  You are incrementing your index before you replace array subset.  So on iteration 0, you wind up replacing at index 1 and completely missed index 0.  Increment at the end of the loop after replacing the element, not before replacing the element.

 

I don't understand the comparisons to 15 and 8.  That seems like odd comparisons when you would be looking at a range of 0 to 9.  Something seems very awkward about comparing to those two numbers, and the use of 3 shift registers to track values when you are only incrementing two indices.

 

Yes you don't want to increment or decrement your index on the column in the iteration where you are also incrementing a row.  So work that into your logic.

 

You probably want to stop your while loop when you hit stop OR you've reached the end of your replacements.

 

I would consider making two For Loops, one that iterates for rows, the inside one iterates for columns.  Shift registers on both to maintain the array.  Then use the i value of the inner loop to replace your element when you are in even rows, or the 9-i element when you are in odd rows.

 

Since your indices are integer values, you should be using the blue integer datatype rather than orange floating point wires.

0 Kudos
Message 3 of 7
(2,400 Views)

for my application, I need store the number 10 in first row of left to right, in the second row for right to left, and so on. I am used a up-down Counter for the positions of  columns, for this  reason the comparation.

There are a signal for control of counter, when this is 8 or 15, the row change of value and the counter of  column position change of direction. 

0 Kudos
Message 4 of 7
(2,393 Views)
Solution
Accepted by angoav98

Ah got an idea what you are trying to achieve and made a quick example. Check it

 

2D Array-10 - corrected.png

 

Good luck

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 7
(2,391 Views)

very well friend. Is perfect

0 Kudos
Message 6 of 7
(2,388 Views)

Put the array indicator inside the loop and you don't need to write to the value property node.

 

This is more along the lines of what I said, (though Panand's implementation was pretty close.)  I cleaned up a few other things.

 

Message 7 of 7
(2,383 Views)