From: joseph Frank on
is there a possibility to load in a loop the files in a directory that start with a certain word. For example, 300 files start with the word portfolio but each has a different number such as portfolio4511,portfolio3256 etc...
is it possible to load them one by one in a loop?
thx
From: Andy on
"joseph Frank" <josephfrank1969(a)hotmail.com> wrote in message <i376nl$qt3$1(a)fred.mathworks.com>...
> is there a possibility to load in a loop the files in a directory that start with a certain word. For example, 300 files start with the word portfolio but each has a different number such as portfolio4511,portfolio3256 etc...
> is it possible to load them one by one in a loop?
> thx

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F
From: Mark Shore on
"joseph Frank" <josephfrank1969(a)hotmail.com> wrote in message <i376nl$qt3$1(a)fred.mathworks.com>...
> is there a possibility to load in a loop the files in a directory that start with a certain word. For example, 300 files start with the word portfolio but each has a different number such as portfolio4511,portfolio3256 etc...
> is it possible to load them one by one in a loop?
> thx

Here is one quick way to do so with a script for files in the current directory:

selectfiles = dir ('portfolio*.mat');
for n = 1:length(selectfiles)
load (selectfiles(n).name)
'Do something here...'
end;

I'm sure more elegant ways will be suggested.
From: Mark Shore on
"joseph Frank" <josephfrank1969(a)hotmail.com> wrote in message <i376nl$qt3$1(a)fred.mathworks.com>...
> is there a possibility to load in a loop the files in a directory that start with a certain word. For example, 300 files start with the word portfolio but each has a different number such as portfolio4511,portfolio3256 etc...
> is it possible to load them one by one in a loop?
> thx

Here is one quick way to do so with a script for files in the current directory:

selectfiles = dir ('portfolio*.mat');
for n = 1:length(selectfiles)
load (selectfiles(n).name)
'Do something here...'
end;

I'm sure more elegant ways will be suggested.