LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Output arrays keep appending when running the vi multiple times

Solved!
Go to solution

Hello everyone,

 

I'm not sure what a problem is and how to name it so please excuse my confusing subject. Basically, I had a subVI which converts a 2D string array into a 1D string array and also eliminate unwanted elements in the 1D array. So I called that subvi in another vi where the input is a 2D string array which has different column sizes:

a b c

d e

so LV automatically fills in the blank with either empty string or "0" if the array is a double array.

Since I have two different arrays, I want the subvi to be executed simultaneously, but every time I run this vi, the array outputs from my convert2Dto1Darray keep appending on the results from the previous run rather than update the output arrays even though in that subvi I created an invoke node for both input and output arrays to programmatically reinitialize the arrays to their default values which are an empty array.

 

It did some research on simultaneous run on subvi and has set shared clone reentrant execution on the subvi, but it didn't fix the problem. 

 

Any help would be greatly appreciated!

MV

 

0 Kudos
Message 1 of 7
(3,037 Views)
Solution
Accepted by topic author dmvpdx

The shift register is uninitialized, so it keeps data from previous runs. Feed an empty array in to initialize it.

Convert2DArrayto1DArray.png

0 Kudos
Message 2 of 7
(3,030 Views)

Fixed! Thank you so much Gregoryj!!

0 Kudos
Message 3 of 7
(3,019 Views)

Please attach the actual VI instead of pictures and snippets. Your entire code seems extremely convoluted With way too much duplicate and inefficient code, but yest, the uninitialized shift register is the main cause of your observed problem.

LabVIEW does NOT support "ragged" arrays, so all rows (or columns res.) of a 2D array are the same length.

0 Kudos
Message 4 of 7
(3,017 Views)

What I want to do is to load multiple csv files, then compare the data in those csv data in pairs, say that I have 3 csv files (can be more than 3)

first.csv

second.csv

third.csv

I need to compute the differences of the data in first and second, first and third, second and third, then compare the three differences with the threshold (come from sampling bunch of data), output the ones that lower than thresholds and their associated file names to a table.

 

I know the way I code is hard to follow but I can't think of any better way to do this.

MV

Download All
0 Kudos
Message 5 of 7
(3,003 Views)
Solution
Accepted by topic author dmvpdx
  • We are still missing some subVIs.
  • As I said, eliminate duplicate code. For example, the two FOR loop stack on the left could be combined into one stack.
  • Unless the files are gigantic, it would be sufficient to read each exactly once and then pairwise operate on the data instead. You are currently reading most files multiple times for no reason.
  • Your subVI could be dramatically simplified using a conditional tunnel.eliminate.png
Message 6 of 7
(2,940 Views)

Hi altenbach,

Sorry for not posting that missing vi. I hesitated to include that vi because it's still under construction and super super messy. I've been getting headache about that vi for a few days. Anyways thank you so so much for all the helpful feedback and suggestion! My main vi has been simplified DRAMATICALLY with the conditional tunnel method and as you suggested, finally I found the way to combine the operation of the two for loops in one. It was so obvious and easy but somehow I couldn't see it Smiley Mad 

Thanks again!

MV

0 Kudos
Message 7 of 7
(2,921 Views)