MATLAB: Read .txt file data with data between specific lines “string” . txt I want to read data between ( strings ) line starting from " *Node " and ending at and next (strings ) line " *Element, type=C3D4" . Best Answer 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. Related SolutionsMATLAB: 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} MATLAB: How to read the tab delimited with skipping the first row I would use the textscan function instead. Something like this would work:fidi = fopen(filename,'rt');D = textscan(fidi, '%f%f%f%f', 'Delimiter','\t', 'HeaderLines',2, 'CollectOutput',1);Experiment with it to get the result you want. Related QuestionConcatenate data using fgets
Best Answer