From: Edwin on
Hello,

I have some problems assigning a variable string to the name of a structure:
name = 'fileName1';
fileName1.a = A1;
fileName1.b = B1;

name = 'fileName2';
fileName2.a = A2;
ect..

After reading the manual I managed to assign the name to a variable using GENVARNAME and EVAL, but only for:
fileName1 = A or a.fileName1 = A
instead of the desired
fileName1.a = A

On other problem is that EVAL prints all the matrix elements (256x256x180) in the Command Window.. I tried ECHO OFF but that didn't help.

Any suggestions?
Thank in advance!

Edwin
From: someone on
"Edwin " <erotgans(a)few.vu.nl> wrote in message <hseg6o$cpp$1(a)fred.mathworks.com>...
> Hello,
>
> I have some problems assigning a variable string to the name of a structure:
> name = 'fileName1';
> fileName1.a = A1;
> fileName1.b = B1;
>
> name = 'fileName2';
> fileName2.a = A2;
> ect..
>
> After reading the manual I managed to assign the name to a variable using GENVARNAME and EVAL, but only for:
> fileName1 = A or a.fileName1 = A
> instead of the desired
> fileName1.a = A
>
> On other problem is that EVAL prints all the matrix elements (256x256x180) in the Command Window.. I tried ECHO OFF but that didn't help.
>
> Any suggestions?
> Thank in advance!
>
> Edwin

Although not EXACTLY an answer to your question,
take a look at the answer to Q4.6 of the MATLAB FAQ at:

http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Oleg Komarov on
"Edwin " <erotgans(a)few.vu.nl> wrote in message <hseg6o$cpp$1(a)fred.mathworks.com>...
> Hello,
>
> I have some problems assigning a variable string to the name of a structure:
> name = 'fileName1';
> fileName1.a = A1;
> fileName1.b = B1;
>
> name = 'fileName2';
> fileName2.a = A2;
> ect..
>
> After reading the manual I managed to assign the name to a variable using GENVARNAME and EVAL, but only for:
> fileName1 = A or a.fileName1 = A
> instead of the desired
> fileName1.a = A
>
> On other problem is that EVAL prints all the matrix elements (256x256x180) in the Command Window.. I tried ECHO OFF but that didn't help.
>
> Any suggestions?
> Thank in advance!
>
> Edwin

All you can is:

name = 'fileName1';
Dataset.(name).a = 1;
Dataset.(name).b = 2;

name = 'fileName2';
Dataset.(name).a = 3;
Dataset.(name).b = 4;

But you cannot do:
name = 'filename1';
(name).a = 3;

Oleg
From: Matt J on
"Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hseiut$b9p$1(a)fred.mathworks.com>...

>
> All you can is:
>
> name = 'fileName1';
> Dataset.(name).a = 1;
> Dataset.(name).b = 2;
>
> name = 'fileName2';
> Dataset.(name).a = 3;
> Dataset.(name).b = 4;
==========


Once you've done the above you could (although it is inadvisable) use my structvars tool

http://www.mathworks.com/matlabcentral/fileexchange/26216-structure-fields-to-variables

to unpack the fields of Dataset into the workspace:

>>eval(structvars(Dataset).')

>> fileName1

fileName1 =

a: 1
b: 2

>> fileName2

fileName2 =

a: 3
b: 4
From: Edwin on
Alright, I will try to bye-pass the problem.

Thank you both!

Edwin