LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

combining two arrays

Solved!
Go to solution

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
0 Kudos
Message 1 of 9
(3,417 Views)
Solution
Accepted by topic author Jagwa

Hi Jagwa,

 

first: use a shift register instead of tunnels. This way the result of the first iteration isn't lost in the 2nd Smiley Wink

"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"...

Message Edited by GerdW on 11-23-2009 09:56 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(3,410 Views)

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. 

0 Kudos
Message 3 of 9
(3,401 Views)

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)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(3,391 Views)
The 1001 is multiplied by two to take the both rows
0 Kudos
Message 5 of 9
(3,387 Views)

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

0 Kudos
Message 6 of 9
(3,382 Views)

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...

Message Edited by GerdW on 11-23-2009 10:32 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 9
(3,381 Views)
i have a sneaky suspicion that the prob is in the subVI. thanks for the help
Message Edited by Jagwa on 11-23-2009 03:35 AM
0 Kudos
Message 8 of 9
(3,375 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 9
(3,351 Views)