LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build arrays from case conditions

Solved!
Go to solution

Hi everyone! I have 2 arrays of 10 elements each and I want to build a new one based on these.The first array consists of integer values range from 0 to 9.(it can be 0,1,2...8,9 but also any other combination with these numbers such as 0,0,1,2,2...7 etc.). The 2nd array consists of double precision numbers.The integer values are time frames and the first element of the energy array (as you can see at the picture i have attached) belongs to the time frame indicated by the first element of the frame array,the second to the second and so on.So what i want to do is, to sort the energy values according to the time frame they belong.I used a case structure and it seems to work but later, with larger arrays it gets really complicated, can you suggest any easier way? I've attached a picture of my code if i didn't make my self very clear...Thanks. 

0 Kudos
Message 1 of 4
(2,306 Views)
Solution
Accepted by cocopa

Hi cocopa,

 

there are other ways too:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(2,289 Views)

GerdW's code is much more efficient and I was going to suggestion something similar.  Your shift registers do nothing and aren't needed as well as the constant wired to the N terminal.  Since the For loop is auto-indexing, no need to wire anything there.  In order to build an array based on an input array, you will need a shift register for looping.  Try GerdW's code, it will probably work for your application.

-----------------------------------------------------------------------------------------
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 3 of 4
(2,271 Views)

Thank you very much for your replies!Yes, that's excactly what i was looking for,i knew that there had to be an easier way to do it but i couldn't figure it out..Thanks again!

0 Kudos
Message 4 of 4
(2,265 Views)