01-06-2010 09:49 PM
01-06-2010 10:14 PM
Well, binary is not at all the same as plain text so notepad and Excel would not be able to interpret the contents correctly. In addition, the default binary storage in LabVIEW is big endian.
Since the reader program is evidently able to export the data as ASCII text, what is the problem? Are you wondering how to modify the main program to save as text? You did not include any of the file save/file read functions so I'm not sure what would be required. There might be other major changes required. Binary storage is often used when high speeds are required.
01-06-2010 11:06 PM
01-07-2010 03:41 PM
The data seems like it can only be read by LabVIEW because LabVIEW is set up to properly read the binary data and it is simple for a user to do.
For matlab to read the data, it will have to be properly configured.
FOPEN - Open a file
FREAD - Binary file read
FWRITE - Binary file write
FTELL - Return the current file position
FSEEK - Set file position indicator
FCLOSE - Close a file
An example is given from http://www.mathworks.com/support/tech-notes/1400/1403.htm:
%This m-file is a short example of how to read and write a binary file
%in MATLAB using low level routines
%write file
fid = fopen('square_mat.bin','wb') %open file in binary write mode
fwrite(fid, 'This is a square matrix', 'char'); %insert a header
fwrite(fid, [1 2 3; 4 5 6; 7 8 9]', 'int32'); %write data to file
fclose(fid); %close file
%read in the same file
fid = fopen('square_mat.bin','rb') %open file
bintitle = fread(fid, 23, 'char'); %read in the header
title = char(bintitle')
data = fread(fid, [3 inf], 'int32') %read in the data
data_tranpose = data' %must transpose data after reading in
fclose(fid) %close file
As you can see, the data type, size, array size, etc. has to be explicitly defined. In addition, as Dennis alluded to, LabVIEW stores binary data in Big-Endian format, wheras most windows applications use little endian. I assume matlab is one of those applications...but I am not a huge matlab developer. Google may have more information on that. You can use a typecast in matlab to convert big to little and little to big, however, so that may be a great place to start. Please see http://www.mathworks.com/access/helpdesk/help/techdoc/ref/typecast.html
Of course, our wonderful applications engineers at National Instruments have already done the above work for you and developed Knowledgebase 11SF83W0: How do I Transfer Data Between The MathWorks, Inc. MATLAB® Software Developm...which is easily searchable from ni.com knowledgebase category using 'matlab binary'