X-Received: by 10.224.205.138 with SMTP id fq10mr21954319qab.1.1370548589681;
        Thu, 06 Jun 2013 12:56:29 -0700 (PDT)
X-Received: by 10.50.88.101 with SMTP id bf5mr424410igb.0.1370548589644; Thu,
 06 Jun 2013 12:56:29 -0700 (PDT)
Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!feeder.erje.net!us.feeder.erje.net!newspeer1.nac.net!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!p1no3320694qaj.0!news-out.google.com!10ni1120qax.0!nntp.google.com!ch1no2761975qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: comp.soft-sys.matlab
Date: Thu, 6 Jun 2013 12:56:29 -0700 (PDT)
In-Reply-To: <koqcic$a$1@newscl01ah.mathworks.com>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=202.78.152.105;
 posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
NNTP-Posting-Host: 202.78.152.105
References: <kooa9o$3fm$1@newscl01ah.mathworks.com> <koob5t$bo9$1@speranza.aioe.org>
 <koqcic$a$1@newscl01ah.mathworks.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <73749802-2445-4a56-8f1f-6025fba73aad@googlegroups.com>
Subject: Re: ncread inside loop
From: TideMan <mulgor@gmail.com>
Injection-Date: Thu, 06 Jun 2013 19:56:29 +0000
Content-Type: text/plain; charset=ISO-8859-1
Lines: 95
Xref: news.mathworks.com comp.soft-sys.matlab:796825

On Friday, June 7, 2013 4:15:08 AM UTC+12, Jonathan W Smith wrote:
> Thanks for the response.  
> 
> 
> 
> the ncread function for netcdf files needs the actual characters of the name. ncread('filename.nc', 'varname')
> 
> 
> 
> Once you have used dir to load the multiple files how do you load the actual filenames with the single quotes into ncread?  Is there a netcdf file command that reads in multiple netcdf files?
> 
> 
> 
> This command allows you to do this: data_files = {'filename.nc', 'filename2.nc'} but, I have 44 files and do not want to write out 44 file names.
> 
> 
> 
> Thanks
> 
> Jonathan
> 
> 
> 
> "Nasser M. Abbasi" wrote in message <koob5t$bo9$1@speranza.aioe.org>...
> 
> > On 6/5/2013 4:24 PM, Jonathan W Smith wrote:
> 
> > > Hello:
> 
> > >
> 
> > > How do I read multiple netcdf files with ncread inside?
> 
> > >
> 
> > > I could list every file name like this:
> 
> > >
> 
> > > data_files = {'filename.nc', 'filename2.nc'}.  How can I avoid this?
> 
> > >For netcdf files, is there a command like dir for ascii and text files?
> 
> > >
> 
> > > Jonathan
> 
> > >
> 
> > 
> 
> > Yes, there is a command like dir in Matlab, it is called dir :)
> 
> > 
> 
> > EDU>> help dir
> 
> > 
> 
> > just do
> 
> > 
> 
> >     A=dir('*.nc')
> 
> > 
> 
> > and A will contain the names of all the .nc files in
> 
> > the current folder. It is an struct array that has
> 
> > one file in each struct.
> 
> > 
> 
> > --Nasser
> 
> > 
> 
> > 
> 
> >

You're not listening..........
Follow Nasser's advice.
Then:
for ifile=length(A)
     t=ncread(A(ifile).name,'time');
     etc
     etc
end

Also, quit top posting.
It makes the thread hard to follow.
Put your reply UNDERNEATH.