i=i-1; if y(i)<=0.98 n=1; end t2=t(i); if t1>t2 ts2=t1; else
ts2=t2; end end
ts2
wn=sqrt(K1/(T*T1)) z=1/2*sqrt(T/(K1*T1)) wd=wn*sqrt(1-z.^2) end
please input T=5 please input T1=3 please input K1=2
Transfer function: 2 ---------------- 15 s^2 + 5 s + 2
mp =
19.8831 tp =
9.6073 ts2 =
22.5276
wn =
0.3651
z =
0.4564 wd =
0.3249
T=input('please input T='); T1=input('please input T1='); K1=input('please input K1='); num=K1;
den=[T*T1 T K1]; G=tf(num,den)
%判断系统是否稳定 [z,p,k]=tf2zp(num,den); i=find(real(p)>0); n=length(i);
if(n>0)
disp('the system is unstable')
disp('it is no use for getting 动态参数')
else
%调用求取二阶系统阶跃响应动态参数的函数文件 [y,x,t]=step(num,den); figure(1) plot(t,y)
xlabel('time-sec') ylabel('y(t)')
title('step responce') figure(2)
pzmap(num,den) [mp,ind]=max(y);
%求取时间向量的长度dimt dimt=length(t);
%确定最终的稳定值yss yss=y(dimt);
mp=100*(mp-yss)/yss tp=t(ind) % find ts2 i=dimt+1;n=0; while n==0 i=i-1; if i==1 n=1; elseif y(i)>=1.02 n=1; end end
t1=t(i);i=dimt+1;n=0; while n==0 i=i-1;
if y(i)<=0.98 n=1; end t2=t(i); if t1>t2 ts2=t1; else ts2=t2; end end
ts2
wn=sqrt(K1/(T*T1)) z=1/2*sqrt(T/(K1*T1)) wd=wn*sqrt(1-z.^2) end
please input T=9 please input T1=1 please input K1=2
Transfer function: 2