📄 quanlity.m
字号:
% ====================================
% PID性能指标计算和显示
% ====================================
% 输入:y1——滤波后的曲线Y值
% wwa——响应曲线全部数据
% temp9——t0时所对应的数组下标
function quanlity(y1,wwa,temp9)
L1=length(y1); % Y数组长度
disp('初始值和稳态值:');
[mm1,mm3]=twostate(y1,wwa) % 计算两个稳态值即:Y(0)和Y(inf)
% 超调量
y1max=max(y1);
disp('————————————');
disp(' 超调量')
chao=((y1max-mm3)/mm3)*100
% 确定上升10%和90%时的Y值
y1_10=(mm3-mm1)*0.1+mm1;
y1_90=(mm3-mm1)*0.9+mm1;
% 确定10%时时间
temp6=0;
temp4=0;
for i5=1:L1
if abs(y1_10-y1(i5,1))<0.01 % 0.005为阀值
temp6=temp6+1;
temp4=wwa(i5,1)+temp4;
end
end
t1_10=temp4/temp6;
% 确定90%时时间
temp6=0;
temp4=0;
for i5=1:L1
if abs(y1_90-y1(i5,1))<0.01 % 0.005为阀值
temp6=temp6+1;
temp4=wwa(i5,1)+temp4;
end
end
t1_90=temp4/temp6;
% 确定上升时间tp
disp('-------------------------------')
disp(' 上升时间')
tp=t1_90-t1_10
% 确定调整时间
% 确定 t0
for i6=1:L1-1
if wwa(i6,3)~=wwa(i6+1,3)
t0=wwa(i6,1); % 确定t0
end
end
% 确定最后进入稳态值+5%~~-5%时间tl
y1add5=(mm3-mm1)*0.05+mm3;
y1sub5=-(mm3-mm1)*0.05+mm3;
% 确定稳态值+5%~~-5%时时间
i=1;
for i5=1:L1
if abs(y1add5-y1(i5,1))<0.004||abs(y1sub5-y1(i5,1))<0.004 % 0.005为阀值
sumi(i)=i5;
i=i+1;
end
end
t_5=wwa(max(sumi),1);
disp('-------------------------------')
disp(' 调整时间')
tl=t_5-t0
% 确定稳定时所对应的时间下标tt
i=1;
for i5=1:L1
if abs(mm3-y1(i5,1))>0.01 % 0.01为阀值
tee(i)=i5;
i=i+1;
end
end
tt=max(tee);
% ISE
y4 = wwa(:,4);
sume2=0;
for i7=temp9:tt
sume2=sume2+(y4(i7))^2*(wwa(i7+1,1)-wwa(i7,1));
end
disp('-------------------------------')
disp(' ISE')
sume2
% 控制器输出信号平滑性
sumu=0;
for i7=temp9:tt
sumu=sumu+abs(wwa(i7+1,7)-wwa(i7,7));
end
disp('-------------------------------')
disp(' 控制器输出信号平滑性')
sumu
% IAE
sume=0;
for i7=temp9:tt
sume=sume+abs(y4(i7))*(wwa(i7+1,1)-wwa(i7,1));
end
disp('-------------------------------')
disp(' IAE')
sume
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -