⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pid_objfun_mse.m

📁 -PID controller has been extensively used in the industrial world. But in this controller it is dif
💻 M
字号:
%Initial_PID_objfun_MSE.m
%Written by Ian Griffin July 2003
%Last Modified 20-08-03
%____________________________________________________________________
function [x_pop, fx_val]=PID_objfun_MSE(x_pop,options)
global sys_controlled
global time
global sysrl
%____________________________________________________________________
Kp=x_pop(2);
Ki=x_pop(3);
Kd=x_pop(1);
%____________________________________________________________________
%creating the PID controller from current values
pid_den=[1 0];
pid_num=[Kd Kp Ki];
pid_sys=tf(pid_num,pid_den); %overall PID controller
%Placing PID controller in unity feedback system with 'sysrl'
sys_series=series(pid_sys,sysrl);
sys_controlled=feedback(sys_series,1);
%____________________________________________________________________
time =0:0.1:30;
[y t] = step(sys_controlled,time); % Step response of closed-loopsystem
%____________________________________________________________________
%Calculating the error
for i=1:301
error(i) = 1-y(i);
end
%Calculating the MSE
error_sq = error*error';
MSE=error_sq/max(size(error));
%____________________________________________________________________
%Ensuring controlled system is stable
poles=pole(sys_controlled);
if poles(1)>0
MSE=100e300;
elseif poles(2)>0
MSE=100e300;
elseif poles(3)>0
MSE=100e300;
elseif poles(4)>0
MSE=100e300;
elseif poles(5)>0
MSE=100e300;
end
fx_val=1/MSE;
%_____________

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -