Peggy Posted July 24, 2019 Share Posted July 24, 2019 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 read in Matlab 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 Link to comment Share on other sites More sharing options...
sgrobler Posted September 16, 2019 Share Posted September 16, 2019 Thanks for posting your code Peggy, Iv'e managed to use it to view some data. Did you find out any more about what is in the header? Maybe that contains things like number of channels, sample rate etc? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.