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

📄 ultimate_pid_objfun_mse.m

📁 -PID controller has been extensively used in the industrial world. But in this controller it is dif
💻 M
字号:
%Ultimate_PID_objfun_mse.m
%Written by Ian Griffin July 2003
%Last Modified 20-08-03
%____________________________________________________________________
function [x_pop, fx_val]=Ultimate_PID_objfun_mse(x_pop,options)
%global sys_controlled
global time
global Ball_Hoop_d
Kp=x_pop(2);
Ki=x_pop(3);
Kd=x_pop(1);
%creating the PID controller from current values
pid_den=[1 0];
84
pid_num=[Kd Kp Ki];
pid_sys=tf(pid_num,pid_den); %overall PID controller
%discretising the pid controller
pid_sysd=c2d(pid_sys,.01,'tustin');
%Placing discrete PID controller in unity feedback system with
'sysrl'
sys_series=pid_sysd*Ball_Hoop_d;%series(pid_sys,Ball_Hoop_rls);
sys_controlled=feedback(sys_series,1);
time =0:0.01:8;
u=.4*ones(size(time));
[y t] = lsim(sys_controlled,u,time); % Step response of closedloop
system to
% an input of 0.4.
for i=1:801
error(i) = 0.4-y(i);
end
error_sq = error*error';
MSE=error_sq/max(size(error));
%____________________________________________________________________
%Making sure overall system is stable
poles=pole(sys_controlled);
if abs(real(poles(1)))>1
MSE=100e306;
elseif abs(imag(poles(1)))>1
MSE=100e306;
elseif abs(real(poles(2)))>1
MSE=100e306;
elseif abs(imag(poles(2)))>1
MSE=100e306;
elseif abs(real(poles(3)))>1
MSE=100e306;
elseif abs(imag(poles(3)))>1
MSE=100e306;
elseif abs(real(poles(4)))>1
MSE=100e306;
elseif abs(imag(poles(4)))>1
MSE=100e306;
elseif abs(real(poles(5)))>1
MSE=100e306;
elseif abs(imag(poles(5)))>1
MSE=100e306;
end
fx_val=1/MSE;
%____________________________________________________________________

⌨️ 快捷键说明

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