www.pudn.com > xml3.rar > ste.m


function [errs,sigma,tp,ts]=ste(y,t) 
[mp,tf]=max(y); 
cs=length(t); 
yss=y(cs); 
errs=trapz(t,abs(y-yss).*t); 
sigma=(mp-yss)/yss;   %计算超调量 
tp=t(tf);     %计算峰值时间   
%tp=tf     %计算峰值时间   
 
%计算调节时间 
i=cs+1; 
n=0; 
while n==0 
    i=i-1; 
    if i==1 
        n=1; 
    elseif y(i)>1.05*yss, 
        n=1; 
    end; 
end 
t1=t(i); 
cs=length(t);j=cs+1; 
n=0; 
while n==0 
    j=j-1; 
    if j==1 
        n=1; 
    elseif y(j)<0.95*yss,     %选择5%的误差带 
        n=1; 
    end; 
end; 
t2=t(j); 
if t1==0 
    ts=t2; 
else 
    if t2t2 
            ts=t1; 
        end 
    else 
        if t2