Prev: Signal Phase Shift (co-phased signals)
Next: Portfolio optimization using minimum-variance (fmincon)
From: joseph Frank on 2 Aug 2010 15:36 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 2 Aug 2010 15:44 "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 2 Aug 2010 15:59 "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 2 Aug 2010 16:22
"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. |