How to call a structure whose name is assigned to another variable???
2 views (last 30 days)
I am trying to get the data from a structure but I the problem I am facing is that I am not able to call the Structure though a variable which cointains the structure name. When I am writng the name of the structure specifically then its fine but not otherwise. Can anyone be able to help.
Steven Lord on 26 Jun 2015
I recommend that you call LOAD with an output argument.
data = load('mymatfile.mat');
Now you can access, for example, the variable named x that was stored in mymatfile.mat as:
More Answers (1)
Adam on 26 Jun 2015
I'm not really sure I understand the question, but if you mean that a field name is assigned to a variable you can do e.g.
fieldName = 'Data';
result = someStruct.( fieldName );
to access a field using a dynamic string from a variable rather than a hard-coded name.