Prev: imread "file does not exist" error matlab R2010a
Next: output lines from text file whose string contains a specificword.
From: Hu Le on 4 Aug 2010 18:26 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) My pseudo code looks something like this: fid = fopen('file.txt') t = fread(fid, '*char')' if strfind(t, 'GPGGA') fwrite (fout, t) end fclose('all')
From: us on 4 Aug 2010 18:35
"Hu Le" <h.thanh.le(a)gmail.com> wrote in message <i3cpds$hf8$1(a)fred.mathworks.com>... > 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) > > My pseudo code looks something like this: > > fid = fopen('file.txt') > t = fread(fid, '*char')' > > if strfind(t, 'GPGGA') > fwrite (fout, t) > end > > fclose('all') where's your GPGGA in your example(?)... us |