From: Gonzalo on
Hi there,

Does anybody know how to assign a name to a variable loaded with command "load"? or at to find out which is the name of the variable just loaded?

Thanks,
G
From: Matt Fig on
Is this what you have in mind?

D = load('clown');
fieldnames(D)
From: Gonzalo on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <i0b11o$91e$1(a)fred.mathworks.com>...
> Is this what you have in mind?
>
> D = load('clown');
> fieldnames(D)

Thanks Matt. Below is the trick...

B = getfield(A,char(fieldnames(A)));

Thanks again.
From: Steven Lord on

"Gonzalo " <glpita(a)gmail.com> wrote in message
news:i0b1tv$63n$1(a)fred.mathworks.com...
> "Matt Fig" <spamanon(a)yahoo.com> wrote in message
> <i0b11o$91e$1(a)fred.mathworks.com>...
>> Is this what you have in mind?
>>
>> D = load('clown');
>> fieldnames(D)
>
> Thanks Matt. Below is the trick...
>
> B = getfield(A,char(fieldnames(A)));

Why not use dynamic field names?

D = load('clown');
fields = fieldnames(D);
B = D.(fields{1});
fields{1}
whos -file clown
whos B

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com