Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: about textread
Date: Thu, 17 Apr 2008 20:19:03 +0000 (UTC)
Organization: Drexel University
Lines: 44
Message-ID: <fu8bbn$rbf$1@fred.mathworks.com>
References: <fu4tt6$rjq$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1208463543 28015 172.30.248.35 (17 Apr 2008 20:19:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Apr 2008 20:19:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1084889
Xref: news.mathworks.com comp.soft-sys.matlab:463717



"Wu Zhiyong" <wuzhiyong_163@163.com> wrote in message
<fu4tt6$rjq$1@fred.mathworks.com>...
> I have a lot of data to read into matlab.They are printed 
> in the textfile as followed:
> 
> airpressure staions  bias      MAE     RMSE    HR          
>   200.0       44   1.82511   2.34681  2.78835  22
> airpressure staions  bias      MAE     RMSE    HR
>  300.0        38   1.55661   1.83753  2.44242  26
>  &#8230;&#8230;
> I need to ignore the characters. I did it in two ways.
> 
>  1.delete the characters manually.And write the code as 
> followed:
> 
> [airpress sta bias mae rmse hr]=textread(filename,'%f %f %
> f %f %f %f');
> 
>  2.add the symbol "%" in front of the characters manually:
> 
> %airpressure staions bias      MAE     RMSE    HR          
>   200.0       44   1.82511   2.34681  2.78835  22
> %airpressure staions bias       MAE     RMSE    HR
>  300.0        38   1.55661   1.83753  2.44242  26
>  &#8230;&#8230;
> 
> And write the code as followed:
> 
> [airpress sta bias mae rmse hr]=textread(filename,'%f %f %
> f %f %f %f','commentstyle','matlab');
> 
> Both ways worked.But there are a large number of data 
> files.And it costs too much time.  
>   Do you have any other way to ignore the characters?
>   Any suggestion is appreciated!
>   Thank you!
> 


If you switch to textscan, which is virtually a drop-in
replacement, then you can use fgetl(fid) and this will
remove the entire first line.  If you then use textscan on
the same fid then you won't have to make any changes to the
original text-files.