From: Aldo H on
I have a string saved as some variable. (say W='BLABLABLA') Now I want to load a file with the name BLABLABLA. How do I do this?

I can't just type LOAD W, because the program will search for a file named W.

I could of course type LOAD 'BLABLABLA', but I need to run the code for dozens of files. So I created a cell array (named A) with the names of all the files (as strings). Then I put the entire program in a "for loop" like this:

for q=1:24
filename = A(1,q); %now for example filename = 'BLABLABLA'
LOAD filename %I want it to do something like LOAD 'BLABLABLA'
........ << program code >>........
end
From: Nathan on
On Mar 15, 5:10 pm, "Aldo H" <ald...(a)msn.com> wrote:
> I have a string saved as some variable. (say W='BLABLABLA') Now I want to load a file with the name BLABLABLA. How do I do this?
>
> I can't just type LOAD W, because the program will search for a file named W.
>
> I could of course type LOAD 'BLABLABLA', but I need to run the code for dozens of files. So I created a cell array (named A) with the names of all the files (as strings). Then I put the entire program in a "for loop" like this:
>
> for q=1:24
>     filename = A(1,q);            %now for example filename = 'BLABLABLA'
>     LOAD filename                 %I want it to do something like LOAD 'BLABLABLA'
>     ........ << program code >>........
> end

Have you read the documentation for load? There is a function form of
that command:

S = load(filename)
S = load(filename, variables)
S = load(filename, '-mat', variables)
S = load(filename, '-ascii')
....

Please read the documentation for functions before posting. You will
learn a lot on your own if you do so.

-Nathan
 | 
Pages: 1
Prev: 3d From 2d
Next: transpose question