Counting the number of events and total number of blocks from a file.
Show older comments
I have results of my experiment on a .dat file (.text version is attached here with). It is obtained after doing experiments for several cycles (each cycle is named 'injection#1,injection#2...). I have a program which reads the data eliminating the 'injection' headers and other texts.
PATH = 'E:\MyData\Experiments';
fid=fopen(fullfile(PATH,'Test'));
fgetl(fid) ;
% Skip 1st line (text describing the experiment).
buffer = fread(fid, [1,Inf], '*char') ;
fclose(fid) ;
% Eliminate 'injection' headers.
buffer = regexprep( buffer, 'i.*?\n', '\n') ;
% Convert to numeric type.
data = textscan(buffer, '%f %f %f') ;
x = data{1} ;
y = data{2} ;
time = data{3} ;
data = [data{:}] ;
In this data, each row of number is an 'event'. How can I get the total number of injections and number of events in some injections (for example, number of events in injection 5, or total number of events between injection 5 to 20). I think, this should be done before eliminating the 'injection' headers in the program.
To make more clear, in the attached file there are 94 injections (total injections) and there are 29 events from injection#1 to injection#4 (injection#1: 12 events, injection#2: 6 events, injection#3: 4 events, injection#4: 7 events). As I have a lot of files with a lot of injections, it is difficult to look manually into each file. So, the program should read and give me the total number of injections and number of events between two specified injections.
Accepted Answer
More Answers (0)
Categories
Find more on Low-Level File I/O in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!