Dot-Indexing by Field Name and Formatting as an Array
To access the specific field dot indexing by the structure, I
by the field name in this case Overshoot
can be done. To format this as an array the square brackets []
can be used to convert the cell array to a row vector. To convert this to a column-vector like how it appears in structure, I
we can transpose this by using the .'
term.
Overshoot = [I.Overshoot].';
Test Script:
%Random structure to test%
I(5).RiseTime = [];
I(5).SettlingTime = [];
I(5).SettlingMin = [];
I(5).SettlingMax = [];
I(5).Overshoot = [];
I(5).Undershoot = [];
I(5).Peak = [];
I(5).PeakTime = [];
%Filling the random structure%
for Index = 1: 5
I(Index).RiseTime = rand(1,1);
I(Index).SettlingTime = rand(1,1);
I(Index).SettlingMin = rand(1,1);
I(Index).SettlingMax = rand(1,1);
I(Index).Overshoot = rand(1,1);
I(Index).Undershoot = rand(1,1);
I(Index).Peak = rand(1,1);
I(Index).PeakTime = rand(1,1);
end
Overshoot = [I.Overshoot].';
Ran using MATLAB R2019b
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…