LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format for writing arrays to binary files

Solved!
Go to solution

I'm trying to write to a binary file as a first step in understanding how the saved formats work.

 

Right now, I have two vi's, one writes a single double to a file, and the other writes a 1d array of doubles to a file.

When I read these files into MATLAB, observing the correct format, I successfully get my single double scalar back, but not the array of doubles.  The array comes from 10000 samples of a sin waveform.  I can observe that the output of the sine wave is correct via a waveform graph, and a waveform chart plugged into the Y values of the sine waveform.

I use the same commands in MATLAB for both:

 

fd = fopen('output.bin', 'r', 'b');

input = fread(fd, inf, 'double=>double');

fclose(fd);

Attached are the two variations of the vi.

Download All
0 Kudos
Message 1 of 3
(3,971 Views)
Solution
Accepted by topic author justynnuff

By default LabVIEW writes the size of the array to the first few bytes of the file. I am not sure whether MATLAB interprets that size information. The Write to Binary File has an input to control the saving of the size information.  Try a boolean False wired to "prepend array or string size?"

 

Lynn

Message 2 of 3
(3,964 Views)

Like a charm.  I must have misread that as it defaults to false, thank you.

0 Kudos
Message 3 of 3
(3,959 Views)