USAGE:
% Reads the first line:
Vs = readline('data.dat');
% Reads the 8 line:
Vs = readline('data.dat',8);
% Reads the [1 2 4 8] lines:
Cs = readline('data.dat',[1 2 4 8]);
% Reads from line 8 to 12:
Cs = readline('data.dat',8:12); % or
Cs = readline('data.dat',[8 12]');
% Reads from 7 to end of file:
Cs = readline('data.dat',[7 -1]');
% Reads from 12 to the last but three lines:
Cs = readline('data.dat',[12 -4]');
NOTES:
- Vs output is a single string vector.
- Cs output is a cell array of strings.
- If the user needs a matrix string output, put 1 as a third option:
Ms = readline('data.dat',[12 -4]',1);
DESCRIPTION:
This program reads specified line(s) from an ascii file, into a string row vector or (if several lines) into a cell array of strings (it can be a matrix string if you force it).
The program tries to read from the first line up to the last specified line, so, it don't has to read the whole file.
FINALLY:
You can save the readed lines with SAVEASCII function as the following example:
saveascii(readline('data1.dat',[3:7],1),'data2.dat') |