11-22-2011 05:34 AM
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.
Solved! Go to Solution.
11-22-2011 06:43 AM
11-22-2011 07:20 AM
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.
11-22-2011 07:31 AM
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!