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

📄 pid1df_sim.m

📁 内模控制器(IMC)工具箱。包括参数整定、PID控制器参数转换等
💻 M
📖 第 1 页 / 共 2 页
字号:
        subplot(2,1,2);plot(t,effort,'m');
        title(['Control efforts when Epsilon = ',num2str(temp)])
   		xlabel('Time'); ylabel('Output'); 
   		grid on;
         hold on
      elseif plot_setpoint
		subplot(2,1,2);plot(t,simout,'m');
        title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   		xlabel('Time'); ylabel('Output'); 
   		grid on;
   		hold on;
      else
      	plot(t,simout,'m');
			title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   		xlabel('Time'); ylabel('Output'); 
         if isempty(keep) | ~keep
            h=text(x_position,y_position,temp1);
            set(h,'color','m');
	   		y_position=y_position-y_scale;
         end
   		grid on;
         hold on
      end
      
   end

end

if   max(real(roots(PIDrealden))) < 0
   if plot_real_PID
   	if plot_setpoint   
   		Setpoint=1;
   		Disturb=0;
   		if col > 1      
    			[t]=sim('realpid1df2',time,options);
   		else
            [t]=sim('realpid1df',time,options);
         end
      	if plot_effort
   			subplot(2,1,1);plot(t,simout,'r');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
         if isempty(keep) | ~keep
            h=text(x_position,y_position,'* realizable PID');
            set(h,'color','r');
   			y_position=y_position-y_scale;
         end
   			grid on;
   			hold on;
            
            subplot(2,1,2);plot(t,effort,'r');
				title(['Control efforts when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
            hold on;
         elseif plot_disturb
   			subplot(2,1,1);plot(t,simout,'r');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
         	if isempty(keep) | ~keep
               h=text(x_position,y_position,'* realizable PID');
               set(h,'color','r');
	   			y_position=y_position-y_scale;
            end
   			grid on;
            hold on;
         else
   			plot(t,simout,'r');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
         	if isempty(keep) | ~keep
               h=text(x_position,y_position,'* realizable PID');
               set(h,'color','r');
	   			y_position=y_position-y_scale;
            end
   			grid on;
   			hold on;
         end
      end
      
      if plot_disturb
         Setpoint=0;
   		Disturb=1;
   		if col > 1      
     			[t]=sim('realpid1df2',time,options);
   		else
            [t]=sim('realpid1df',time,options);
         end
        if plot_effort
   			subplot(2,1,1);plot(t,simout,'r');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
         	if isempty(keep) | ~keep
               h=text(x_position,y_position,'* realizable PID');
               set(h,'color','r');
	   			y_position=y_position-y_scale;
            end
   			grid on;
   			hold on;
            
            subplot(2,1,2);plot(t,effort,'r');
				title(['Control efforts when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
            hold on;
         elseif plot_setpoint
            subplot(2,1,2);plot(t,simout,'r');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
   			hold on;
         else
            plot(t,simout,'r');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
         	if isempty(keep) | ~keep
               h=text(x_position,y_position,'* realizable PID');
               set(h,'color','r');
	   			y_position=y_position-y_scale;
            end
   			grid on;
   			hold on;
         end
      end
   end
else
   plot_real_PID=0;
   real_PID_Enable='off';
end
if c1>=0 & c2>=0 & Alpha>=0 & max(real(roots(PID1lagden))) < 0
	if plot_1_lag_PID   
      if plot_setpoint
         Setpoint=1;
      	Disturb=0;
      	if col > 1
     			[t]=sim('pid1lag2',time,options);
      	else
            [t]=sim('pid1lag',time,options);
         end
        if plot_effort
            subplot(2,1,1);plot(t,simout,'b');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
         	if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 1st order lag*PID');
               set(h,'color','b');
	   			y_position=y_position-y_scale;
            end
      		grid on;
      		hold on;
            
            subplot(2,1,2);plot(t,effort,'b');
				title(['Control efforts when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
            hold on;
         elseif plot_disturb
            subplot(2,1,1);plot(t,simout,'b');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
         	if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 1st order lag*PID');
               set(h,'color','b');
	   			y_position=y_position-y_scale;
            end
      		grid on;
            hold on;
         else
            plot(t,simout,'b');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 1st order lag*PID');
               set(h,'color','b');
	   			y_position=y_position-y_scale;
            end
      		grid on;
            hold on;
         end
      end
      
      if plot_disturb
      	Setpoint=0;
      	Disturb=1;
      	if col > 1
     			[t]=sim('pid1lag2',time,options);
      	else
            [t]=sim('pid1lag',time,options);
         end
         if plot_effort
            subplot(2,1,1);plot(t,simout,'b');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 1st order lag*PID');
               set(h,'color','b');
	   			y_position=y_position-y_scale;
            end
      		grid on;
      		hold on;
            
            subplot(2,1,2);plot(t,effort,'b');
				title(['Control efforts when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
            hold on;
         elseif plot_setpoint
            subplot(2,1,2);plot(t,simout,'b');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
            hold on;
         else
            plot(t,simout,'b');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 1st order lag*PID');
               set(h,'color','b');
	   			y_position=y_position-y_scale;
            end
   			grid on;
            hold on;
         end
      end
   end
else
   plot_1_lag_PID=0;
   lag1_PID_Enable='off';
end

if max(real(roots(PID2lagden))) < 0
	if plot_2_lag_PID
      if plot_setpoint
         Setpoint=1;
      	Disturb=0;
      	if col > 1
        		[t]=sim('pid2lag2',time,options);
      	else
            [t]=sim('pid2lag',time,options);
         end
         if plot_effort
            subplot(2,1,1);plot(t,simout,'g');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 2nd order lag*PID');
               set(h,'color','g');
	   			y_position=y_position-y_scale;
            end
      		grid on;
      		hold on;
            
            subplot(2,1,2);plot(t,effort,'g');
				title(['Control efforts when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
            hold on;
         elseif plot_disturb
            subplot(2,1,1);plot(t,simout,'g');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 2nd order lag*PID');
               set(h,'color','g');
	   			y_position=y_position-y_scale;
            end
      		grid on;
            hold on;
         else
            plot(t,simout,'g');
				title(['Setpoint Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 2nd order lag*PID');
               set(h,'color','g');
	   			y_position=y_position-y_scale;
            end
      		grid on;
            hold on;
         end
      end
      if plot_disturb
         Setpoint=0;
      	Disturb=1;
      	if col > 1
        		[t]=sim('pid2lag2',time,options);
      	else
            [t]=sim('pid2lag',time,options);
         end
         if plot_effort
            subplot(2,1,1);plot(t,simout,'g');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 2nd order lag*PID');
               set(h,'color','g');
	   			y_position=y_position-y_scale;
            end
      		grid on;
      		hold on;
            
            subplot(2,1,2);plot(t,effort,'g');
				title(['Control efforts when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
   			grid on;
            hold on;
         elseif plot_setpoint
            subplot(2,1,2);plot(t,simout,'g');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
      		grid on;
            hold on;
         else
            plot(t,simout,'g');
				title(['Disturbance Step Response when Epsilon = ',num2str(temp)])
   			xlabel('Time'); ylabel('Output'); 
	         if isempty(keep) | ~keep
               h=text(x_position,y_position,'* 2nd order lag*PID');
               set(h,'color','g');
	   			y_position=y_position-y_scale;
            end
      		grid on;
            hold on;
         end
      end
	end
else
   plot_2_lag_PID=0;
   lag2_PID_Enable='off';
end
old_handle=gcf;
clear  PID1lagden PID2lagden PIDrealden simout effort t
 coord
 

⌨️ 快捷键说明

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