LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help

Hello,

 

I am new to labview and I am having difficulty creating an array and writing it to a spread sheet. I have a for loop that generates 3 data values every interation. I would like to write these values to a 2d spread sheet with three colums. I attached a sample VI, but I dont know what is wrong. Thanks.

0 Kudos
Message 1 of 6
(2,600 Views)

Try something like this:

 

 

(Your main problem is that you start with an empty array and try to insert at column 1. This place does not exists. Start with index zero.)

 

Message Edited by altenbach on 03-26-2009 09:47 AM
0 Kudos
Message 2 of 6
(2,594 Views)

Heres a quick way to do it:

 

The cool thing about For loops is that they will auto-index.
So when you pass each of the 3 values out of the array, they will each build a 1-D array.

Each of these will act as a column, so if you use a 'Build Array' function, it will combine all 3 1D arrays into a 2D array.

Then use a 'Write to Spreadsheet File' function 

 

Edit: darn, too slow Smiley Wink

Message Edited by Cory K on 03-26-2009 11:51 AM
Cory K
0 Kudos
Message 3 of 6
(2,584 Views)

Cory,

 

Your code would generate three rows instead of three columns. You would need to transpose for writing. This is the reason I was using "build array" inside the FOR loop.

0 Kudos
Message 4 of 6
(2,562 Views)

altenbach wrote:

Cory,

 

Your code would generate three rows instead of three columns. You would need to transpose for writing. This is the reason I was using "build array" inside the FOR loop.


Oh, you're right, I didnt check which way the array was oriented. Oh well, nothing a quick 'Transpose Array' cant fix. Smiley Wink

Cory K
0 Kudos
Message 5 of 6
(2,558 Views)
... or simply wire a TRUE to the "transpose?" input of "write to spreadsheet file". 😄
0 Kudos
Message 6 of 6
(2,549 Views)