Jump to content

an easy way to read log file by MATLAB


Recommended Posts

Hi everyone,

I found an easy way to read .log file by MATLAB.  MATLAB has functions to read binary file but the difficulty is that we are not sure about the header and format of the log data. I am not familiar with Python so the other way that posted by benl using Python is such a pain to me.

Here are a few lines that can easily decode .log file with two channels of data:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Read Data from OpenLogger file
close all;clear;clc
logfilename = '20190723_9_0.log';
finfo = dir(['F:\' logfilename]);
channelNum = 2; %number of channels
sampleNum = finfo.bytes/2/channelNum;
fileID = fopen(logfilename);
logdata = fread(fileID,[channelNum sampleNum],'int16=>int16');
fclose(fileID);
headerNum=257;
plot(logdata(1,headerNum+1:end),'-'),hold on %channel 1
plot(logdata(2,headerNum+1:end),'-'),hold off %channel 2

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

WaveForms Live

image.png.0e50caa9860fc85a17b5f626dbe58022.png

read in Matlab

 

image.png.7b1b40aa452230ee23ad15b05a618cfb.png

Note: I don't care about the header info so I just get rid of it. I use random input pulses for ch2; The two plots are not from the same time.

 

peggy

 

image.png

Link to comment
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...