LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort array and save it in a new array

Hallo,
I have 3 files, each of them contains an 2D array with 1000 rows and 10 column. I want to sort them file by file. From File1 , i take row number X, X-1, X-2 and then (X+30), (X+30)-1 , (X+30)-2 and then (X+60), (X+60)-1, (X+60)-2 , and so on....after file1 is finished, it will look file2 and so on....
I have written this program, but unfortunately when it look at file 2,the result of file1 will be added to the result of file2, so the result of file2 = result of file1 + (the actually) result of file2.
How to make that result of file 2 is pure from file 2 (not mixed with result of file1)
Thanks a lot
0 Kudos
Message 1 of 4
(2,667 Views)
The feedback node near the center of your diagram is not initialized, thus data from earlier runs are forming a buildup.
The issue is complicated because you have a FOR loop inside a while loop. An initialized feedback node does not work well if you have stacked loops. You need to replace it with a shift register and add another shift register on the WHILE loop. Now you need to initialize the lefmost shift register at the WHILE loop boundary with an empty array. (see attached, LV7.1)

I don't have the luxury of 2000x2000 monitor resolution, thus I compacted your diagram a little bit. My work slows down if I constantly have to scroll. 😉

Do you really want the result file to be numbered "n", while the input file is numbered "n+1"? This seems confu
sing. I modified a few codelets, e.g. your method to get the number of rows seems overly complex. I'm pretty sure your loops could be simplified too, but I did not bother to investigate.
Message 2 of 4
(2,667 Views)
Additional comment: You should really place everything after the "file read" in a case structure wired to the error-out. You don't want to do any computation or file operation if the read fails and there is no data! (see attached code image)
0 Kudos
Message 3 of 4
(2,667 Views)
Hallo Mr Altenbach ,
Thank you very much for your help. It works perfect.
Thanks

Jimmy
0 Kudos
Message 4 of 4
(2,667 Views)