On Monday, July 1, 2013 9:59:09 AM UTC+12, Negin Nazarian wrote:
> Hello all,
>
>
>
> I have an ascii file that I need to process. It is in this format:
>
> "
>
> "Surface Integral Report"
>
>
>
> Area-Weighted Average
>
> Radiation Heat Flux (w/m2)
>
> -------------------------------- --------------------
>
> wall 34.189476
>
> wall_aw 28.288052
>
> ---------------- --------------------
>
> Net 34.208313
>
>
>
> Area-Weighted Average
>
> Radiation Heat Flux (w/m2)
>
> -------------------------------- --------------------
>
> wall 34.324566
>
> wall_aw 28.363642
>
> ---------------- --------------------
>
> Net 34.345776
>
> "
>
> and the file has more than 1000 of this sets but all I need is the "Net" values. How can I use textscan in a way that reads the file and only make an array of Net values?
>
>
>
> Any help is appreciated.
>
> Cheers,
>
> Negin
One way is to read all the lines in as strings:
c=textscan(fid,'%s');
then to look for the lines with Net in them:
indx=strmatch('Net',c{1});
and process those to extract the numbers using str2num
> Hello all,
>
>
>
> I have an ascii file that I need to process. It is in this format:
>
> "
>
> "Surface Integral Report"
>
>
>
> Area-Weighted Average
>
> Radiation Heat Flux (w/m2)
>
> -------------------------------- --------------------
>
> wall 34.189476
>
> wall_aw 28.288052
>
> ---------------- --------------------
>
> Net 34.208313
>
>
>
> Area-Weighted Average
>
> Radiation Heat Flux (w/m2)
>
> -------------------------------- --------------------
>
> wall 34.324566
>
> wall_aw 28.363642
>
> ---------------- --------------------
>
> Net 34.345776
>
> "
>
> and the file has more than 1000 of this sets but all I need is the "Net" values. How can I use textscan in a way that reads the file and only make an array of Net values?
>
>
>
> Any help is appreciated.
>
> Cheers,
>
> Negin
One way is to read all the lines in as strings:
c=textscan(fid,'%s');
then to look for the lines with Net in them:
indx=strmatch('Net',c{1});
and process those to extract the numbers using str2num