From: Walter Roberson on
Hu Le wrote:
> Hello! i'm very new to Matlab and need some help.
>
> I have a text file that looks something like this:
>
> $KEEP,16
> $REMOVE,20
>
> $KEEP,17
> $REMOVE,201
>
> $KEEP,12
> $REMOVE,2012
>
> I'm having trouble creating a Matlab script that will allow me to read
> from the above text file and generate another text file that looks
> something like this:
>
> $KEEP,16
> $KEEP,17
> $KEEP,12
>
> Basically, preserve only the lines with the word "KEEP" in it and remove
> the rest (eg. $REMOVE... and break line)

I wouldn't bother using Matlab for this: I would just use "sed" or "awk" or
"perl".


> t = fread(fid, '*char')'

fread() is for binary. If you want to do line by line processing, consider fgetl()


ps: what does textscan() say about Comments ?