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,:);endNote ā This is UNTESTED CODE, since I do not have your file to test it with. Related SolutionsMATLAB: Read .txt file data with data between specific lines “string” . The textscan function using a numeric format descriptor string will automatically stop when it encounters: *Element, type=C3D4so this is actually a straightforward problem: fidi = fopen('Copy_of_Job-1.txt','rt');D = textscan(fidi, '%f%f%f%f', 'HeaderLines',9, 'Delimiter',',', 'CollectOutput',1);fclose(fidi);with āDā being a (1418x4) double matrix. MATLAB: Cannot Read data from text file FileID = fopen('data.txt','r');C = textscan(FileID,'%s %f %f','HeaderLines',1,'Delimiter',',');fclose(FileID);C{1}C{2}C{3} Related QuestionI want to delete all the headerlines and delimiters from the data in the below attached text filePlotting multiple series on one graph from a text file
Best Answer