How to get 2% and 5% settling time from simulink?
Mostra commenti meno recenti
Hello,
I am simulating a simple open loop control system, as part of it I need to output the 2% and 5% settling time from simulink to check against my matlab and hand calc results. Can anyone help me with outputting the 2% and 5% settling time on simulink?
Risposte (2)
Hi @Daniel
Below, you'll find the calculation for the settling time based on the 5% criterion:
%% System
zeta= 1/2;
wn = 1;
sys = tf(1, [1 2*zeta*wn wn^2])
%% Assume that response data {Time t, Output y} is sent to Workspace
[y, t] = step(sys);
%% Settling time (5% criterion)
yfinal = 1; % steady-state response value
S = stepinfo(y, t, yfinal, 'SettlingTimeThreshold', 5/100);
Ts = S.SettlingTime
%% Plot result
plot(t, y), grid on
xline(Ts, '--', 'Settling time', 'LabelVerticalAlignment', 'bottom'),
yline(1.05, '--', '+5% threshold')
xlabel t, ylabel y(t)
Update: Demo using Simulink model

%% ----- This part can be skipped ----
load("responseData.mat");
G = tf(1, [1 8.52 5.3 26]);
step(G), grid on
% ------------------------------------
%% Computation of settling times based on 2% and 5% criteria
yfinal = 1/26; % steady-state response value
S2 = stepinfo(out.out, out.t, yfinal);
Ts2 = S2.SettlingTime % 2% criterion
S5 = stepinfo(out.out, out.t, yfinal, 'SettlingTimeThreshold', 5/100);
Ts5 = S5.SettlingTime % 5% criterion
7 Commenti
Daniel
il 22 Feb 2024
Sam Chak
il 22 Feb 2024
Hi @Daniel
You're already familiar with how to send the logged data to the Workspace, as demonstrated in your Simulink model. The same syntax can be utilized to calculate the settling time based on the 5% criterion (the default is 2%).
%% Settling time (5% criterion)
yfinal = 1/26; % steady-state response value
S = stepinfo(out.out, out.t, yfinal, 'SettlingTimeThreshold', 5/100);
Ts = S.SettlingTime
Sam Chak
il 22 Feb 2024
Hi @Daniel
To illustrate the computation of the settling time, I need to generate some step response data in the MATLAB online platform. However, when using Simulink, you can skip the following section of the code.
%% System
zeta= 1/2;
wn = 1;
sys = tf(1, [1 2*zeta*wn wn^2])
%% Assume that response data {Time t, Output y} is sent to Workspace
[y, t] = step(sys);
Daniel
il 22 Feb 2024
Sam Chak
il 22 Feb 2024
Ah, I see, @Daniel. It seems the reason for the discrepancy is that I sent the logged data to the Workspace as an Array, while yours are likely in the form of a Structure. However, as long as you specify the data type correctly, the syntax should work just fine. I'm glad to hear that it's working out for you. 👍
Daniel
il 22 Feb 2024
Paul
il 22 Feb 2024
0 voti
Hi Daniel,
I'm interpreting your question to mean that you have a Simulink model of the system and in Simulink you stimulate the system with a step input and wish to compute the settling time of the output, which is logged by a To Worspace block or something similar.
1 Commento
Daniel
il 22 Feb 2024
Categorie
Scopri di più su Naming Conventions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



