Settling time functionality - definition of duration
6 views (last 30 days)
Show older comments
Samuel Foster
on 24 Apr 2025
Commented: Samuel Foster
on 28 Apr 2025
According to the settling time functions documentation:
"s = settlingtime(x,d) returns the time from the mid-reference level instant to the time instant each transition enters and remains within a 2% tolerance region of the final state over the duration d."
I initially interpreted this as the transition is considered 'settled' if it enters a 2% tolerance and then remains within that tolerance for a duration d. Instead the documentation also gives the following definition:
"Settle-seek duration [d] in seconds, specified as a positive scalar. This argument defines the duration after the mid-reference level instant that settlingtime looks for a settling time."
So this means if the step response happens to be within the tolerance at time mid-reference level+d then it is considered settled.
Consider the example attached. The step response does not continuously remain within the tolerance for longer than 1s at any point, so if I set a duration of say 3s then I would expect the function to output NaN. Instead it gives me the black circle since 3s after the mid-reference level happens to be within tolerance (green square). Setting the duration to either 2s or 4s does not give a settling time as expected since the value of the response at time mid-reference level+d is outside of the tolerance (purple and blue squares).
How can I calculate the settling time with these two 'duration' parameter interpretations set to two different values. I.e. I want the function to search for a duration d1 during which the step response remains with tolerance, but it should only search until it reaches a duration d2 after the mid-reference level.
4 Comments
Mathieu NOE
on 25 Apr 2025
ok, so you answered yourself
as your signal is not settling (not steady) using this function can lead to improper results
settling time is (IMHO) only meaningfull if your response is damped which is not your case
I don't know what was the purpose of yiur question , at least you have demonstrated it's not a case for using settlingtime
if the question is to find whatever points in the curve , maybe we have to figure out another approach
Accepted Answer
Mathieu NOE
on 25 Apr 2025
I could suggest this simple code to answer your last question
the first plot shows where the data is within 2% tolerance band (i.e +/- 1% in the code) ; there are 3 segments and we will the one that has a duration above 5s
load('step_response_2_order.mat')
t = P_data(:,1);
x = P_data(:,2);
y = P_data(:,3);
dt = mean(diff(t));
Fs = 1/dt;
y_final = y(end);
ind = abs(y-y_final)<=0.01; % where the data is within 2% tolerance band (i.e +/- 1% in the code)
[begin,ends] = find_start_end_group(ind); % in samples
figure
plot(t,x,t,y,t,ind,'r*');
% now keep only begin,ends values for a duration above given threshold
dur_min = 5; % seconds
duration = ends - begin; % in samples
ii = find(duration>=dur_min*Fs);
% final selection
select = NaN(size(t));
select(begin(ii):ends(ii)) = 1;
% start / end time stamps
beginS = begin(ii)*dt % in seconds
endsS = ends(ii)*dt % in seconds
% final plot
figure
plot(t,x,t,y,t,select,'r*');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [begin,ends] = find_start_end_group(ind)
% This locates the beginning /ending points of data groups
% Important : ind must be a LOGICAL array
D = diff([0;ind(:);0]);
begin = find(D == 1);
ends = find(D == -1) - 1;
end
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing 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!