Read LabView binary file timestamp into Matlab

  • Follow


In case it is useful to someone:
If you need to read a LabView binary data file into Matlab, it is
tricky to read in the time data because of the way that LabView writes
its timestamp into the binary file.  Note that the LabView time
convention is miliseconds since Jan 1 1904.  Here is one approach (may
contain errors but will point you in the right direction),

%% Read in date information
[ fid, msg ] = fopen(FileName, 'r') ;
NColumns = 60 ; % Number of data columns - probably different for your
dataset!
[a, count] = fread(fid, [ NColumns Inf], '*single') ; % Force data to
be read into Matlab workspace as singles
a = a' ; % Convert to data in columns not rows
% The last two columns of a are the timestamp
b  = fliplr(a(:, end-1:end)) ; % Must swap the order of the columns
d = typecast(reshape(b',[],1), 'double') ; % Now we can can convert to
double
time_local = datenum(1904, 1, 1) + d/(24*3600) ; % Convert from
seconds to matlab time format
fclose(fid) ;

%% Read in data columns
[ fid, msg ] = fopen(FileName, 'r') ;
[ a, count ] = fread(fid, [ NColumns inf ], 'float') ;
fclose(fid) ;
a = a' ; % Columns of data
0
Reply ke 9/21/2010 3:09:18 PM


0 Replies
579 Views

(page loaded in 0.055 seconds)

Similiar Articles:













7/20/2012 2:49:46 PM


Reply: