Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How can I process a sequence of files?
Date: Wed, 24 Oct 2012 04:29:08 +0000 (UTC)
Organization: HSBC
Lines: 63
Message-ID: <k67qqk$e27$1@newscl01ah.mathworks.com>
References: <k67lhs$qf4$1@newscl01ah.mathworks.com> <37a94bd9-3381-4093-8c94-1aca939b6cc5@googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1351052948 14407 172.30.248.45 (24 Oct 2012 04:29:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 24 Oct 2012 04:29:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2921053
Xref: news.mathworks.com comp.soft-sys.matlab:781281

Thanks for the look, TideMan.  Here is the image that I see:
http://postimage.org/image/akp1ml5yn/

This seems to be a free image hosting site.  I've never tried it before today.  Can you see the pic???

TideMan <mulgor@gmail.com> wrote in message <37a94bd9-3381-4093-8c94-1aca939b6cc5@googlegroups.com>...
> On Wednesday, October 24, 2012 3:59:08 PM UTC+13, Ryan  wrote:
> > How can I process a sequence of files?
> > 
> > Hello Matlab experts.  Im trying to figure out a way to read all CSV files in a directory, and similarly, Im trying to figure out a way to read all text files in a directory. 
> > 
> > 
> > 
> > I tried the following code.  This compiles, and runs fine, but it doesnt do anything close to what I want to do.  
> > 
> > p=dir('C:\AllCSVFiles1\*.csv');
> > 
> > num = cell(size(p));
> > 
> > text = cell(size(p));
> > 
> > all = cell(size(p));
> > 
> > for i=1:length(p)
> > 
> >     [num{i}, text{i}, all{i}]= xlsread(['C:\AllCSVFiles1\', p(i).name]);
> > 
> > end
> > 
> > 
> > 
> > The following compiles and runs, but it doesnt seem to be any better than the first code sample:
> > 
> > dirname = uigetdir;
> > 
> > Files = dir(fullfile(dirname,'*.csv'))
> > 
> > j =0;
> > 
> > for k = 1:numel(Files)
> > 
> >   filename = fullfile(dirname,Files(k).name);
> > 
> >   x = dlmread(filename,'\t'); %# I assume tab-delimiter
> > 
> >   j = j + size(x, 1);
> > 
> >   xlswrite( 'sample_output', x, 'Sheet1',sprintf('A%d',j) )
> > 
> > end
> > 
> > 
> > 
> > 
> > 
> > Basically, Im trying to import several different files (all files in a folder) into a single Matlab variable (data from 1st file is imported, data from 2nd file is stacked under the 1st, data from 3rd file is stacked under the 2nd, etc.).  Or, as an alternative, data from each file is put into its own respective variable.  Does anyone have any idea about how I can do this???
> > 
> > 
> > 
> > Thanks!!
> 
> Your first method should work.
> What is wrong with the result?