|
If you are writing a loop, check for blank lines by using the strtrim and isempty function. e.g if each line is read in variable tline (say)
if isempty(strtrim(tline))
%% blank line so skip
continue;
else
%% add to array
end
using strtrim in case blank line is not really blank but has white space characters so strtrim returns an empty character string.
Alternative to writing loop would be trying textread function. If you comments are of matlab, shell, c, or C++ style ..textread has a 'commenstyle' parameter you can specify which will make it skip all the lines that begin with the comment character. Look at help textread - its a useful function.
~S
"Mike Giordano" <sakar321@gmail.com> wrote in message <h0ognp$rg6$1@fred.mathworks.com>...
> Hello all,
>
> I am trying to write an m-file to import data that is set up in the following way:
>
> {Some line with comments}
>
> #data
> #data
> #data
>
> {Line with comments}
>
> #data
> .....
>
> The number of lines of "data" are different throughout the file so I was thinking the best way to do this would be to write a loop that puts everything between blank lines into a new array.
>
> My big question is: is there a way to do this in matlab? How do I read a blank line?
>
> Thanks in advance for any help.
|