Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
Newsgroups: comp.soft-sys.matlab
Subject: Re: .dat file in Matlab
References: <1166596683.099803.309980@73g2000cwn.googlegroups.com>
From: Peter Boettcher <boettcher@ll.mit.edu>
Message-ID: <m3k60meivj.fsf@coyote.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.4 (gnu/linux)
Cancel-Lock: sha1:b6PG8Mhp3PfWYnuW5RsOCYzCS9E=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 23
Date: Wed, 20 Dec 2006 09:34:24 -0500
NNTP-Posting-Host: 155.34.163.30
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1166624478 155.34.163.30 (Wed, 20 Dec 2006 09:21:18 EST)
NNTP-Posting-Date: Wed, 20 Dec 2006 09:21:18 EST
Xref: news.mathworks.com comp.soft-sys.matlab:384614



"mishra" <mishradh@gmail.com> writes:

> Hi,
> I was trying to assign file as an array of y, like y(1)=load name.dat.
> Since I have lot of .dat files and I want to assign them as in an array
> of y vaules, to be used later in program. Can anyone advise me on this.

Use a cell array:

y{1} = load('name.dat');

Or, since your name will be dynamic:

for i=1:10
  fname = sprintf('file%i.dat', i);
  y{i} = load(fname);
end


-- 
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/