12-29-2008 09:17 AM
Hi,
I've got two questions about building arrays within while loops. I'm using LabView 8.5.1.
In its simplest form, my current while loop (time delay set at 0.2s) has 3 variables which are changed by moving a slider. These are each sent to a line within a "Build Array" block (data type is DBL 1D) - this array is then written to a spreadsheet file, such that the three values are written to a new row each time (one value per column) the while loop runs.
Question 1
How can I add a "Time" column into this spreadsheet? In other words, get the current time that the loop has been running for, starting at 0 seconds into the spreadsheet, via the Build Array block.
I can think how to do this with a For loop, but given that the While loop is running through an unknown number of iterations, I can't figure out how to get the counter to work.
Question 2
How can I have text column headings in the spreadsheet?
Thanks for the help, and if you require anything clarifying, please let me know 🙂
Solved! Go to Solution.
12-29-2008 10:48 AM - edited 12-29-2008 10:50 AM
To answer question 1:
There is an 'Elapsed Time' function that you can put as the first colum of data.
This will then format your spreadsheet as
Time Data1 Data2 Data3
Time Data1 Data2 Data3
Time Data1 Data2 Data3
etc....
To answer question 2:
Build an array of the headings, then write that array to the file once, outside of the loop.
Your array with the time and data will write inside the loop.
12-29-2008 10:51 AM - edited 12-29-2008 10:52 AM
This will work. Although it is easiest, its not the most efficient method.
The Write To Spreadsheet vi opens and closes the file every time. For better performance, open the file manually at the start, write your data as it goes, and then close the file at the end of the program.
😎
12-29-2008 11:28 AM