Problem with accessing struct in a struct
Show older comments
Hi Matlab community
I have the following problem. I created a code which does system identification with various samples of simulation data to get various output error models. In order to save all of them I created the following code:
for i = 1:laenge
....
sys = oe(data,[1 2 0]);
sys_oe.A = sys.A;
sys_oe.B = sys.B;
sys_oe.C = sys.C;
sys_oe.D = sys.D;
sys_oe.F = sys.F;
sys_oe.NoiseVariance = sys.NoiseVariance;
sys_oe.Ts = sys.Ts;
oe_sum.numerierung_str(i) = sys_oe;
end
numerierung_str is a string array which using letters to numerate starting from 'a', 'b', ...
The idea was to access the individual parameters (sys_oe.A, ...) of each model and rebuilt it through idpoly by using the command oe_sum.a.A etc.
In my case, in the workspace there is the "variable" oe_sum which contains one field "numerierung_str" and one value "1x19 struct". When I open that I get a kind of table (which is actually a structure array).
Why didnt my idea work out accessing the variable/array in the struct in the struct by using the command oe_sum.a.A for example?
Using the command oe_sum.numerierung_str.A(1) or oe_sum.numerierung_str.A(1,1) gives me the following error:
"Intermediate dot '.'
indexing produced a
comma-separated list with 19
values, but it must produce
a single value when followed
by subsequent indexing
operations.
Related documentation"
When I type "oe_sum.numerierung_str(1)" in the Workspace, the following is displayed:
struct with fields:
A: 1
B: 0.0552
C: 1
D: 1
F: [1 … ]
NoiseVariance: 1.2973e+05
Ts: 0.0100
How can I access single variables here?
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!