LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ArrayToFile - why only 6 digits ?

Why does ArrayToFile(...) function
write to file only 6-digits after comma
while I have written into array such number: 3.56585255115

in file there were such numbers:

3.565853 and 5.526585


Below there is a snippet of my program \/
===========================================================
scanf ("%d%d", &N_row_samples, &K_col_harmonic);

ptr_matrix=malloc(N_row_samples*K_col_harmonic*sizeof(double));

for ( i = 0; i < N_row_samples; i++ )
for (j = 0; j < K_col_harmonic; j++ ) {

if(i<3) ptr_matrix[(i*K_col_harmonic)+j] = 3.56585255115;
else ptr_matrix[(i*K_col_harmonic)+j] = 5.52658514552;

ArrayToFile ("file.dat", matrix, VAL_DOUBLE,
(N_row_samples*K_col_harmonic), N_row_samples,
V
AL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_TAB,
30, VAL_ASCII, VAL_TRUNCATE);
===========================================================
0 Kudos
Message 1 of 3
(3,139 Views)
Hi,

This looks like the ArrayToFile() writes the data as a Float even though you have specified VAL_DOUBLE. I can confirm this, I am using CVI 5.5. It's best you report this via the Contact Support | Ask an Engineer. Maybe CVI 5.5.1 works better!!!.

You may even have to write your own ArrayToFile function.


Ray.
Regards
Ray Farmer
0 Kudos
Message 2 of 3
(3,139 Views)
The ArrayToFile function dates back a long time to LabWindows/DOS. This function was intended to be a quick way to dump an array into a file in ASCII or binary and is not completely customizable. You should be using FmtFile or the ANSI C file I/O functions if you want custom formatting in the ASCII conversion of numbers.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 3 of 3
(3,139 Views)