LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding two 2-D Arrays to then save

I am trying to build two 2-D arrays to then save as a spreadsheet file. This process happens in while loop and I need to enable indexing when I feed the wire out. When I do this I use the build array fucntion but then it creates a 3-D array which I cannot save.
0 Kudos
Message 1 of 10
(3,668 Views)
If you build the 2D array inside the loop, why do you want auto-indexing on the output...by definition that will give you an array of 2D arrays...? My guess is that what you really need to have is a shift register to hold the 2D array between iterations and then wire the output from the right shift register terminal...but it all depends on how you actually build the array. If you could post a picture or VI with the code we can probably figure out the best way to do it.
0 Kudos
Message 2 of 10
(3,668 Views)
Yeah, you were right.... it works but now the data is being put all into two columns rather then keeping it's original config. I am going to keep trying! I have attached the .vi if you have any suggestions it would be greatly appreciated. Thanks so much!!!
0 Kudos
Message 3 of 10
(3,668 Views)
I'm not sure what your trying to accomplish...could you e.g. provide two test files, some row/column selections and the result you expect?

A couple of comments about the VI as it is now;

* Why read the files twice? Instead of doing that, wire the 2D array output not only to the array dimensions function but into the for-loop where you want it as well. The for loop will by default use auto-indexing on incoming arrays, however if you right-click on the tunnel you can tick off that...and you now only read the file(s) once.

* # of columns across is read using a local when you could just wire the data directly from the terminal. Locals use unnecessary memory and slows things down, the rule is to stick with wires whereever you can.

* When you
extract a sub-array by specifying start column, columns across and # of rows down the output as it is now, if you specify 2 rows, start column 0 and # of columns across does not work as you planned it to I think...the output as it is now is an array of 2 rows where the first row contains columns number 8 and the second row contains column number 9...Now knowing exactly what it is your want to do with the files I'm not sure...but that does not seem to be what you want...or?
0 Kudos
Message 4 of 10
(3,668 Views)
Thank you so much for your indepth input!! I have provided an excel file with my attepted calculations and sample output of the test data I provided. Hopefully this will clear up what I am trying to accomplish.

Thanks again!!
0 Kudos
Message 5 of 10
(3,668 Views)
Ok. I've made an example that processes the whole file(s). Run the process file.vi, input a file pattern and select a directory of test files. Now you can click the process files button and it will produce files containing the results you wanted.

In the example I have not included the option of selecting just a segment of the files. The files are named after their origin file, the name is not put into the file itself...and finally I assume that the files always contain complete sets (you can initialize an array to hold the results instead of reusing the incoming array to avoid this dependancy...).

As you will see generating the result is quite simple, it's all done in the calculate VI. If you want to average across fil
es as well (not just data within one and the same file) it will need modifications though...If you want to be able to select a sub-section of the file the easiest way to do it is to do it prior to feeding the array to the calculate VI...the most effective though would be to modify the logic of the calculation VI slightly so that it can work on a selection directly.

If you sometimes need to be able to calculate the average and deviation of more values than the pairs, that's possible as well, but would require a modification of the calculation vi...

Mads
0 Kudos
Message 6 of 10
(3,668 Views)
In the example the whole result is generated in memory prior to being written to file. If the files are large it may be better to write the averages and deviations to file as soon as they have been calculated...Or, if speed and memory are both factors, the optimal is to combine the two; keeping a given number of preliminary results in a buffer and then only write when that buffer is filled (less memory usage due to disk writing,more speed due to buffering).
0 Kudos
Message 7 of 10
(3,668 Views)
Thanks again for your input and the time you have spent helping me. Unfortunately I am unable to open labview 6.1 because I have labview 6.0...I get a load error 9. Is it possible to downsave this vi or post a pic of the vi???

Cheers!!
0 Kudos
Message 8 of 10
(3,668 Views)
Fired up my old laptop with LV6.1 and converted it back to 6.0 (attached).

Mads
0 Kudos
Message 9 of 10
(3,668 Views)
This works great!! Thanks for your time!! I have learned a lot with your insightful comments!!

Cheers
0 Kudos
Message 10 of 10
(3,668 Views)