The settling time in matlab differs from the calculated value

17 views (last 30 days)
Hi,
Why does Matlab calculate the settling time which measures the time for the error to fall below 2% of the peak value of the error for the closed-loop function T given below differently from the calculated value?
Cheers,
T= 4/( s^2 + 1.6 s+4)
Calculated settling time=4/(wn*zeta)=5 s;
where wn=2, zeta=0.4.
s = stepinfo(T)
s =
struct with fields:
RiseTime: 0.7326
TransientTime: 4.2047
SettlingTime: 4.2047
SettlingMin: 0.9065
SettlingMax: 1.2537
Overshoot: 25.3741
Undershoot: 0
Peak: 1.2537
PeakTime: 1.7269
  2 Comments
Mathieu NOE
Mathieu NOE on 15 Apr 2025
just to recall the exact definition :
  • Settling time (ts) is the time required for a response to become steady. It is defined as the time required by the response to reach and steady within specified range of 2 % to 5 % of its final value.
  • Calculated settling time=4/(wn*zeta)=5 s; is only an approximation of the true value
Matlab gives the correct value
fatih
fatih on 15 Apr 2025
Since the formula Ts=4/(wn*zeta) gives a value that is very different from Matlab's answer, what is the general formula in Matlab that gives a value close to the settling time?

Sign in to comment.

Accepted Answer

Sam Chak
Sam Chak on 15 Apr 2025
From the following computations and the step response plot, you may gain insight into how the actual settling time is measured.
s = tf('s');
%% plant
T = 4/(s^2 + 1.6*s + 4)
T = 4 --------------- s^2 + 1.6 s + 4 Continuous-time transfer function.
[num, den] = tfdata(T, 'v');
%% properties
wn = sqrt(den(end))
wn = 2
zeta = den(2)/(2*wn)
zeta = 0.4000
%% estimated settling time
tsEst1 = 4/(wn*zeta) % textbook formula (lazy version)
tsEst1 = 5
tsEst2 = -log(0.02)/(wn*zeta) % true formula, yet a conservative approximation
tsEst2 = 4.8900
%% measured settling time
ST = stepinfo(T);
tsMeas = ST.SettlingTime
tsMeas = 4.2047
%% step response
step(T), grid on, hold on
plot(tsMeas, 0.98, 'ro')
yline(1.02, '--', sprintf('1.02 threshold'), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'top', 'LabelHorizontalAlignment', 'left')
yline(0.98, '--', sprintf('0.98 threshold'), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom', 'LabelHorizontalAlignment', 'left')
xline(tsEst1, '--', sprintf('Estim1 Settling Time: %.3f s', tsEst1), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom')
xline(tsEst2, '--', sprintf('Estim2 Settling Time: %.3f s', tsEst2), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom', 'LabelHorizontalAlignment', 'left')
xline(tsMeas, '--', sprintf('Actual Settling Time: %.3f s', tsMeas), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom', 'LabelHorizontalAlignment', 'left')
hold off
  3 Comments
Sam Chak
Sam Chak on 15 Apr 2025
There is no closed-form expression to determine the exact settling time. To find it, one must solve the transcendental equation using numerical methods.
s = tf('s');
%% Plant
T = 4/(s^2 + 1.6*s + 4)
T = 4 --------------- s^2 + 1.6 s + 4 Continuous-time transfer function.
[num, den] = tfdata(T, 'v');
%% Extract data
a = den(1);
b = den(2);
c = den(3);
sigma = - b/2; % real part of the pole
omega = sqrt(4*a*c - b^2)/2; % imaginary part of the pole
coeff = b/sqrt(4*a*c - b^2); % coefficient of the sine component
%% Analytical Solution of the Transfer Function
t = linspace(0, 8, 8001);
sol = @(t) 1 - exp(sigma*t).*cos(omega*t) - coeff*exp(sigma*t).*sin(omega*t);
For underdamped 2nd-order linear system:
%% Step response
plot(t, sol(t)), grid on,
xlabel('t'), ylabel('y(t)'), title('Step response')
%% Solve for Settling Time, ts
t0 = 4; % initial guess
ts1 = fsolve(@(t) sol(t) - 1.02, t0)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
ts1 = 5.1417
ts2 = fsolve(@(t) sol(t) - 0.98, t0)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
ts2 = 4.2047

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!