How can I extract data members from stepinfo output in MATLAB?
When the stepinfo
function is run on a transfer function (i.e. stepinfo(tf)
) a typical result is:
RiseTime: 52.2052
SettlingTime: 8开发者_JAVA百科5.4916
SettlingMin: 0.9041
SettlingMax: 1.0012
Overshoot: 0.1192
Undershoot: 0
Peak: 1.0012
PeakTime: 132.8773
I did some research into stepinfo
. It appears it returns a struct. So I assigned the above result to a variable and checked its size using size()
.
It's a 1x1 matrix.
This has me pretty convinced that I cannot extract individual data members from this struct without first assigning it to a string and then performing string manipulations.
I need the Overshoot and PeakTime values, Does anybody know the best way to grab these values without using the P.O. and Tp formulas - and without a huge string mess?
Everything in MATLAB is considered a matrix. A single structure element (which is what is being returned by stepinfo
in your example) is a 1-by-1 matrix of type struct
. You can access the fields of your structure like so:
S = stepinfo(sys); %# Returns a structure, stored in variable S
overShoot = S.Overshoot; %# Get the value in the Overshoot field
peakTime = S.PeakTime; %# Get the value in the PeakTime field
For more information about working with structures, check out this documentation page.
精彩评论