?? stepchar.m
字號:
function [pos,tr,ts2,tp]=stepchar(y,t)
%find pos and tp
%返回階躍響應(yīng)輸出y列向量的最大值mp及對應(yīng)下標(biāo)值ind
[mp,ind]=max(y);
%求取時間向量的長度dimt
dimt=length(t);
%確定最終的穩(wěn)定值yss
yss=y(dimt);
pos=100*(mp-yss)/yss;
tp=t(ind);
% find rise time tr
%確定輸出為0.1時的時刻
i=1;j=1;k=1;q=1;
while y(i)<0.1
i=i+1;
end
t1=t(i);
%確定輸出為0.9時的時刻
while y(j)<0.9
j=j+1;
end
t2=t(j);
tr=t2-t1;
% 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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -