Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to read/import multiple files which have headings
Date: Mon, 9 Jun 2008 13:49:02 +0000 (UTC)
Organization: PSA
Lines: 41
Message-ID: <g2jcce$qve$1@fred.mathworks.com>
References: <g2jbk1$ht2$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1213019342 27630 172.30.248.37 (9 Jun 2008 13:49:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 Jun 2008 13:49:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 474056
Xref: news.mathworks.com comp.soft-sys.matlab:472839



"julia " <julia.krohn@gmail.com> wrote in message
<g2jbk1$ht2$1@fred.mathworks.com>...
> Hi, 
> I am a beginner when it comes to Matlab and am trying now 
> for some time to get my data in the most efficient way into 
> matlab for further processing. Its rather a lot of files 
> (Test1, Test2 ....) which have some headers and are 
> delimited with ; in ASCI format. I was hoping that there is 
> some automation possible: 
> 
> My input gives me an error with the textread and i dont 
> really know how to fix it.  Any help appreciated !
> -----------
> clear all; close all; 
> for k = 1:50
>   textfilename = ['Test' num2str(k) '.ASC'];
>   fid = fopen(textfilename, 'rt');
>   data = textread(fid,'','delimiter',';','headerlines',7);
>   savefile=['Test' num2str(k) '.mat'];  
>   nrows=size(data,1);
>   ncolumns=size(data,2);
>   data=data(:,1:ncolumns-1);
>   lengte = length(data);
>   Time=data(1:lengte,1);
> % then come lots of variable & calc etc which are fine 
> which I omitted here...
>   save(savefile,'Time');
>   fclose(fid);
> end
> --------
> 
> 
> 
Hi,
I think that you should use texscan in place of textread.
Both do the same thing but don't have the same inputs :
textread take as first parameter the name of the file not
the fid while textscan take the fid (file identifier) as
first input.

Caroline