MATLAB: Reading some part of a file

cell arraytextscan

Hello. I have a text file to read and I use the following commands to read the data.
fid = fopen('filename.dat','r');
formatspec = '%8c %6c %6c %d %64c %10c %d %d %s %s %s';
data = textscan(fid,formatspec,'Delimiter',',');
To save memory for the cell "data", I'd like to read only last 3 text strings. Would you please how to read a part of the file?
Many thanks for sharing your time.

Best Answer

  • Replace
    formatspec = '%8c %6c %6c %d %64c %10c %d %d %s %s %s';
    formatspec = '%*8c %*6c %*6c %*d %*64c %*10c %*d %*d %s %s %s';