LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I save 2D array of double precision numbers in spreadsheet format?

I want to save a 2D array of double-precision numbers that is the data I collected using my labview VI. The "write to spreadsheet.vi" does NOT work for me because it writes single precision numbers.
I tried other simple approaches, like using the "write to file.vi" and the binary I16 write to file. But these didn't suit my needs. At the end of the day, I want to save data collected with labview and be able to import it to MATLAB.
It is critical that I be able to save double precision, and not just single precision.
Any ideas on how to do this?
0 Kudos
Message 1 of 8
(5,071 Views)
can't you just open the "write to spreadsheet file.vi", save a copy (as something else) and change the representation of the inputs to double?
Message 2 of 8
(5,071 Views)
jonny e wrote:

> I want to save a 2D array of double-precision numbers that is the data
> I collected using my labview VI. The "write to spreadsheet.vi" does
> NOT work for me because it writes single precision numbers.
> I tried other simple approaches, like using the "write to file.vi" and
> the binary I16 write to file. But these didn't suit my needs. At the
> end of the day, I want to save data collected with labview and be able
> to import it to MATLAB.
> It is critical that I be able to save double precision, and not just
> single precision.
> Any ideas on how to do this?


Hi Jonny,
I always convert all numbers (dbl) to strings first, using the csv
format. This is very simple to do. *.csv files can be used by many
applications and can often be load
end by a double mouse click (Excel).
CSV is described in the Excel help somewhere.
- So take your 2D array and convert it to dbl strings (use
format value), with a "." as decimal separator.
- Slice out the first row of the array (1D-array)
- Concatenate the string cells of this 1D array one by one,
to a line of strings, separated by comas ",".
- terminate the line with CR and NewLine
- Handle each row of your converted dbl 2d-array in the same way.
- Write all lines to a file.

Take a look to the attached sample.csv, once with a editor and once with
Excel. If you need header- strings, use >>"<<, as showed in the example

I hope this helps,

Rainer


### Please remove all numbers in email address for reply ###
0 Kudos
Message 3 of 8
(5,071 Views)
uhm, no...that's the whole point of why i need to save my data as doubles...once saved as single, there's no way to recover the "extra" digits of precision
0 Kudos
Message 4 of 8
(5,071 Views)
oops. my bad...i misunderstood your suggestion the first time around.
good idea...i'll try changing the file write to spreadsheet.vi.
thanks for the help
0 Kudos
Message 5 of 8
(5,071 Views)

 

Just in case there's someone else who wants to solve this.

 

There's a very simple way.

When using "write to spreadsheet.vi", there is a (format) node with default value of (%.3f).

Change (%.3f) into any number you want, (%.10f) for example, then you'll be able to get 10 digits to the right to the decimal point.

0 Kudos
Message 6 of 8
(4,302 Views)

@streetpoet wrote:

 

Just in case there's someone else who wants to solve this.

 

There's a very simple way.

When using "write to spreadsheet.vi", there is a (format) node with default value of (%.3f).

Change (%.3f) into any number you want, (%.10f) for example, then you'll be able to get 10 digits to the right to the decimal point.


This is a very old thread and you missed the point. With the old Write to Spreadsheet, the numeric representation was SGL with only about 6 decimal digits and simply using a format string did nothing to change that.

 

0 Kudos
Message 7 of 8
(4,299 Views)

You may be right but streetpoet answered my question PERFECTLY.

 

Thanks!

0 Kudos
Message 8 of 8
(4,063 Views)