|
On 6/13/2012 12:43 PM, Kuo-Hsien wrote:
> Dear all,
>
> A quick question: how to create a file path string for loading many
> files in with in the same folder?
>
> for example:
>
> a = load ('/data1/HD1/path/subpath/data/subdata/aaa.txt')
>
> I like to create a path string to represent
> /data1/HD1/path/subpath/data/subdata/
>
> path = /data1/HD1/path/subpath/data/subdata/
>
> So, I can use a = load('path/aaa.txt')
...
dname='/data1/HD1/path/subpath/data/subdata/';
file='aaa.txt';
fname=fullfile(dname,file);
a=load(fname);
If you're doing a lot, it may be far simpler to use the results of
d=dir(fullfile(dname,'*.txt'));
and iterate through the members of the .name field returned.
for idx=1:length(d)
a=load(d(idx).name);
% process...
end
--
|