11-23-2009 02:43 AM
Hi,
I have a while loop that runs trough each case in a case structure. Every one of these cases produces a 1d array. How could i combine these arrays into a 2d array. A simple attempt with two cases is attempted in the attached diagram.
The problem is that it seems to fill the first column with zeros when adding the second row to the array
Solved! Go to Solution.
11-23-2009 02:54 AM - edited 11-23-2009 02:56 AM
Hi Jagwa,
first: use a shift register instead of tunnels. This way the result of the first iteration isn't lost in the 2nd
"it seems to fill the first column with zeros" - No, it simply takes the original array again, but now overwriting the second row!
2nd:
When your while loop runs twice all the times why not use a FOR loop instead? No need to check for "i < 1"...
11-23-2009 03:07 AM
thanks, the shift register worked. Im pretty new at this so i didnt know about them.
There is another niggly problem which could use some solving. The when the case structure runs the second case, (which is shown in the diagram) the array produced is the second reading appended to the first reading from the first case.
Is there a way of just getting that second reading for the second case. As you can see i took the subarray out which is the array i want but this will not be able to work for a more complicated program.
11-23-2009 03:25 AM
Hi Jagwa,
it's not entirely clear to me what you are doing in that case:
You get a reading from your device. This will be converted to a 2d array. Then you take the 2nd and the 3rd row (starting from row 2, length 2) with 1001 columns per row. Then you Reshape to a 1d array of just 1001 elements effectively taking only the first of the 2 rows. Something's fishy here...
Why not simply index the converted array to pick the row you need (instead of SubArray)?
11-23-2009 03:28 AM
11-23-2009 03:31 AM
this is what happens
Eg.
Current:
case0 - 1,2,3,4.
case1 -1,2,3,4.
5,6,7,8.
Need:
case0 - 1,2,3,4.
case1 - 5,6,7,8.
without the use of subarray
11-23-2009 03:31 AM - edited 11-23-2009 03:32 AM
Hi Jagwa,
ok, the "2" is hidden in the subvi...
Still don't get your question. I don't know your hardware, so I can't say what you get per reading and how to change the readings...
Edited:
Use IndexArray to pick the second row of the reading for case 2...
11-23-2009 03:34 AM - edited 11-23-2009 03:35 AM
11-23-2009 04:26 AM
Do you use "Subarray" with the 2, to get the 2 first rows in case 2? Thus you'd get the 3 first in case 3 i assume?
Use Index Array instead and you'll get 1 row at a time.
/Y