|
On 8/3/2012 6:21 PM, Kunal wrote:
> Hi,
> I have this data in a txt file:
> time = 0.0000E+00
> mat.#= 1012 inten= 0.0000E+00 kinen= 0.0000E+00 eroded_ie= 0.0000E+00 eroded_ke= 0.0000E+00
> x-mom= 0.0000E+00 y-mom= 0.0000E+00 z-mom= 0.0000E+00
> x-rbv= 0.0000E+00 y-rbv= 0.0000E+00 z-rbv= 0.0000E+00
> mat.#= 1013 inten= 0.0000E+00 kinen= 0.0000E+00 eroded_ie= 0.0000E+00 eroded_ke= 0.0000E+00
> x-mom= 0.0000E+00 y-mom= 0.0000E+00 z-mom= 0.0000E+00
> x-rbv= 0.0000E+00 y-rbv= 0.0000E+00 z-rbv= 0.0000E+00
> mat.#= 1014 inten= 0.0000E+00 kinen= 0.0000E+00 eroded_ie= 0.0000E+00 eroded_ke= 0.0000E+00
> x-mom= 0.0000E+00 y-mom= 0.0000E+00 z-mom= 0.0000E+00
> x-rbv= 0.0000E+00 y-rbv= 0.0000E+00 z-rbv= 0.0000E+00..............
> I want to write a code which reads this text line by line and prints the
> 'mat.#' whose intern=0.0000E+00
I don't see anything where there's a string 'intern'. You mean 'inten'
I suppose???
If the above is the extent of the need, probably simplest to just parse
on the fly...
fid=fopen('yourfile','rt');
while ~feof(fid)
l=fgetl(fid);
if strmatch('mat.#',l)
if sscanf(l(20:30),'%f')==0
disp(l(1:12))
end
end
fid=fclose(fid);
Salt to suit, obviously...
--
|