MATLAB: How to extract this data

data extract

Anyone,
I want to extract the data in the end row.
The meaningful data comes every "0" changes in the first row…
Best,
Pen

Best Answer

One option:
fidi = fopen('your_text_file_name.txt','r');
Data = textscan(fidi, '%f%f%f', 'HeaderLines',4, 'CollectOutput',1);
fclose(fidi);
You might have to add an 'EndOfLine' argument if you only get a (1x1) cell from the previous code:
fidi = fopen('your_text_file_name.txt','r');
Data = textscan(fidi, '%f%f%f', 'HeaderLines',4, 'CollectOutput',1, 'EndOfLine','\r\n');
fclose(fidi);
You can then parse the columns as you wish. Use a cell array. Find the zeros in the first column using the find function:
DataD = cell2mat(Data);
Zeros1 = [find(DataD(:,1) == 0); size(DataD,1)];
for k1 = 1:length(Zeros1)
Record{k1} = DataD(Zeros1(k1):Zeros1(k1+1)-1,:);
end
Note ā€” This is UNTESTED CODE, since I do not have your file to test it with.