📄 timrsp.m
字号:
function [ov_str,rt_str,st_str,pt_str]=timrsp(t,y,ref)
%
% Function TIMRSP is used to calculate the step response
% parameters, such as percent overshot, rising time,
% settling time, peak time.
%
% OVSHOT = TIMRSP(T, Y, REF)
%
% OVSHOT - returns the percent overshot of step response
% T - is the time range vector for simulation
% Y - is the step response result
% REF - the steady state output
%
% Author: Ole Barup Sorensen, Rapid Data Ltd
% Copyright (c) 1989-94 by Rapid Data Ltd
% Revision 10:05 07/02/94
ov_str = ' '; rt_str = ' '; st_str = ' '; pt_str = ' ';
i = find(y > ref(1));
n0 = size(i);
if (n0(1) ~= 0),
rt = 0.5*(t(1,i(1)-1)+t(1,i(1)));
end
n0 = size(t);
ymax = 0;
for i=1:n0(2),
if (y(i,1) > ymax),
ii = i; ymax = y(i,1);
end
end
y1 = [y(n0(2):-1:1,1)];
i = find(abs(y1-ref) > 0.02*ref(1));
if i ~= [],
st = 0.5*(t(1,n0(2)-i(1)+1)+t(1,n0(2)-i(1)));
else
st = t(n0(2));
end
pt = t(1,ii);
ovshot = 100*(ymax-ref(1))/ref(1);
if (ovshot <= 0),
ov_str = 'The system is overdamped';
pt_str = ' ';
else
ov_str = ['The percent overshoot is : ',num2str(round(ovshot)),' %'];
pt_str = ['The peak time is : ',num2str(round(pt*10)/10),' Sec'];
end
if (exist('rt') == 1),
rt_str = ['The rising time is : ',num2str(round(rt*10)/10),' Sec'];
end
n0 = size(t);
if (t(n0(2)) ~= st),
st_str = ['The settling time is : ',num2str(round(st*10)/10),' Sec'];
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -