Hi
I want to load files in matlab by using for loop. There are n number of files whose name are temp1, temp2,temp3.......................& i want to load them as data1, data2,data3 ................................
Please help me on this loop.
Thanks,
Ravi
|
|
0
|
|
|
|
Reply
|
ravi
|
6/2/2010 4:55:20 AM |
|
ravi wrote:
> Hi
>
> I want to load files in matlab by using for loop. There are n number of
> files whose name are temp1, temp2,temp3.......................& i want
> to load them as data1, data2,data3 ................................
>
> Please help me on this loop.
>
> Thanks,
> Ravi
Steve Lord already posted pointing you to a source that describes why
you should not do this, shows you alternatives, and ends by showing how
to do it the way you think you want.
Excerpting, he wrote:
See Q4.12 in the newsgroup FAQ.
DON'T. See Q4.6 for the recommended alternatives.
-- Steve Lord slord@mathworks.com comp.soft-sys.matlab (CSSM) FAQ:
http://matlabwiki.mathworks.com/MATLAB_FAQ
|
|
0
|
|
|
|
Reply
|
Walter
|
6/2/2010 5:07:45 AM
|
|
This one I can answer
initialdirectory = pwd();
cd('/filedirectory/');
allfilenames = dir('*.txt');
for b = 1:length(allfilenames)
filename = allfilenames(b).name;
fid = fopen(filename,'r');
data1 = textscan(fid,'%n','Delimiter','\t');
fclose(fid);
end
If you want different variable names for each file look up eval()
"ravi " <ravi.aher@ge.com> wrote in message <hu4o7o$h6j$1@fred.mathworks.com>...
> Hi
>
> I want to load files in matlab by using for loop. There are n number of files whose name are temp1, temp2,temp3.......................& i want to load them as data1, data2,data3 ................................
>
> Please help me on this loop.
>
> Thanks,
> Ravi
|
|
0
|
|
|
|
Reply
|
Jon
|
6/2/2010 8:09:03 AM
|
|