Thread Subject: syntax problem with LOAD and strings

Subject: syntax problem with LOAD and strings

From: Aldo H

Date: 16 Mar, 2010 00:10:26

Message: 1 of 2

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

Subject: syntax problem with LOAD and strings

From: Nathan

Date: 16 Mar, 2010 00:24:30

Message: 2 of 2

On Mar 15, 5:10 pm, "Aldo H" <ald...@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

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
syntax Aldo H 15 Mar, 2010 20:14:06
string Aldo H 15 Mar, 2010 20:14:06
load Aldo H 15 Mar, 2010 20:14:06
rssFeed for this Thread

Contact us at files@mathworks.com