LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do you create a 2-d array%3F

Solved!
Go to solution

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

0 Kudos
Message 1 of 8
(2,902 Views)

Please post the vi in 2009 version.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 8
(2,897 Views)

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.

 

0 Kudos
Message 3 of 8
(2,892 Views)

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

0 Kudos
Message 4 of 8
(2,884 Views)

Instead of writing it continously you can auto index the values and write to the spreadsheet at the last (as given by BillMe).

 

 

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 8
(2,873 Views)
Solution
Accepted by topic author dav2010

@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


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:
forum dec 12_2012 build 2d array_BD.png
or generate all your values and then write once:
forum dec 12_2012 build 2d array_BD2.png
(fix the broken wire).
Message 6 of 8
(2,872 Views)

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.

0 Kudos
Message 7 of 8
(2,858 Views)

@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.

Message 8 of 8
(2,831 Views)