From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Better precision when saving to spreadsheet

I am saving a 1-D array to a spreadsheet.  I can't get any better than 3 decimal point precision using the write to spread sheet file vi.  I opened up that vi and changed the input representation to double, but that didn't help at all.  Is there an easier way to make my saved values more precise than writing a whole new sub-vi?
 
Also, it there an easy way to label the columns of the spreadsheet even if the data is being saved from inside a while loop?
 
Thanks,
Strass
0 Kudos
Message 1 of 3
(2,452 Views)
Change the format precision at the top of the "save to spreadsheet" vi from the default "%.3f" to "%.xf" where x is the desired number of decimal places. I've made this mistake and lost critical data. Not much fun.
Message 2 of 3
(2,446 Views)
Yes and it is easy, if you look at the write to soreadsheet vi you will find a place for formatting. the default format for this vi is %.3f (read the help syntax for more explanation on this) change this to the syntax that you would like. (%.4f).
This is from labview help.
.Precision or _Significant Digits (optional) When you use a formatting function, . or _ controls the number of digits displayed. If you use ., LabVIEW uses the number that follows as a precision specifier for digits to the right of the decimal point. If you use _, LabVIEW uses the number that follows as the specified number of significant digits to use in the display format.

.Precision—When you use it with floating-point notation, this element specifies the number of digits to the right of the decimal point. If . is not present, LabVIEW uses a precision of six digits. If . is 0, LabVIEW does not insert a precision. When you use it with string parameters, .Precision specifies the maximum width of the scanned field. LabVIEW truncates strings longer than this length.

_Significant Digits—Displays the data by rounding to the number of digits you specify. LabVIEW rounds the data only for display purposes, which does not affect the original data. .Precision affects only the digits to the right of the decimal point, and _Significant Digits includes all non-spacing digits. For example,
  • 3.457 has 4 significant digits
  • 0.0012 has 2 significant digits
  • 123000 has 3 significant digits
Note  You cannot use precision and significant digits together in a single percent code.



Joe.
"NOTHING IS EVER EASY"
Message 3 of 3
(2,444 Views)