12-11-2012 11:29 PM
How do you create and write a 2-d array?? I have two operations in the same WHILE loop. Each execution of the loop should generate a new pair of values.
However, the BUILD ARRAY function only outputs a 1-d array to the WRITE TO SPREADSHEET FILE.vi.
Perhaps, more broadly, how does one put data into a 2-d array as it is collected? I think I am building two arrays simultaneously below, but, what I really want is to build a single 2-d array. Is this how you would do it? It looks clumsy connecting sequential BUILD ARRAY's together. Is this creating a 2-d array that I can search later by index and return the paired data?
Lastly, why does my front panel indicator only show data in the first column?? How do I make it display the data as it is collected across the rows?
Thanks,
Dave
Solved! Go to Solution.
12-11-2012 11:44 PM
Please post the vi in 2009 version.
12-11-2012 11:52 PM - edited 12-11-2012 11:55 PM
For what you are doing, why not just generate all your value pairs (built as a 1D array) inside the loop, then wire the indexed output (2D array) to the Write to Spreadsheet File?
Otherwise, build your 1D array from both scalars (don't use a build array for each which is why you're getting only 1 column of data), then run that into a single build array.
12-12-2012 12:32 AM
Sorry, very simple minded here...how do pairs go as a 1-d array? I thought that (x,y) data must be a 2-d array...a column of "x's" and a column of "y's"? Wouldn't a 1-d array just be all x's? I admit I'm pretty new to understanding arrays.
" build your 1D array from both scalars" --> how do you do this?? I cannot find a "convert to scalar" on the pallette.
Also, here is the vi saved down to 2009, I think.
Dave
12-12-2012 12:56 AM
Instead of writing it continously you can auto index the values and write to the spreadsheet at the last (as given by BillMe).
12-12-2012 12:59 AM - edited 12-12-2012 01:05 AM
Here's a simpler way, just write out your X and Y as a 1D array each iteration. The Write will append your data as a column of X's and a column of Y's:
@dav2010 wrote:
Sorry, very simple minded here...how do pairs go as a 1-d array? I thought that (x,y) data must be a 2-d array...a column of "x's" and a column of "y's"? Wouldn't a 1-d array just be all x's? I admit I'm pretty new to understanding arrays.
" build your 1D array from both scalars" --> how do you do this?? I cannot find a "convert to scalar" on the pallette.
Also, here is the vi saved down to 2009, I think.
Dave
or generate all your values and then write once:
(fix the broken wire).
12-12-2012 07:02 AM
OH, I think I see what you are doing. Each iteration, you are writing a 1-d array of my precious x,y values, and then appending array after array to the spreadsheet without transposing, which means they write in rows instead of columns. So, each data pair is its own 1-d array. Is that correct? Would that same way work with 3 data values, e.g. x,y,z data? I suppose we could write as many elements as inputs we chose the BUILD ARRAY to have.
12-12-2012 06:05 PM
@dav2010 wrote:
OH, I think I see what you are doing. Each iteration, you are writing a 1-d array of my precious x,y values, and then appending array after array to the spreadsheet without transposing, which means they write in rows instead of columns. So, each data pair is its own 1-d array. Is that correct? Would that same way work with 3 data values, e.g. x,y,z data? I suppose we could write as many elements as inputs we chose the BUILD ARRAY to have.
Yes, you are correct.