Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Dynamic file names in nested structures
Replies: 1   Last Post: Mar 10, 2012 10:41 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Michel Slivitzky

Posts: 69
Registered: 12/7/04
Dynamic file names in nested structures
Posted: Mar 10, 2012 7:42 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have the following script rto retrieve values from a structure
% get fieldnames for nested structures; ZZ is a1x1 structure
sig_bassins=fieldnames(ZZ); % first level location
nom_invars=fieldnames(ZZ.ARN); % second level soil type

x = ZZ.ROM.clay1; % will return a 9x3 double variable

% now If I define:
sig_bassins(17) % returns 'ROM'
nom_invars(1) % returns 'clay1'

% and now if I try:
y = ZZ.(sig_bassins(17)).(nom_invars(1)); % returns the following error message
% Argument to dynamic structure reference must evaluate to a valid field name

% what am I doing wrong?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.