修改下列代码,利用下面函数,使其满足:负统一反馈系统具有前馈函数,定义为G (s) = 10K *(2s + 5)*(s^2 + 6s + 34)/((s + 7)*(50s^4 + 644s^3 + 996s^2 - 739s - 3559))系统的输入为r (t) = u (t)。你将需要提供一个Matlab代码来画出三个系统的输出响应,包括无补偿、被动PD和被动PID。 clear all; % Clear all memory clc; % Clear our screen syms t s; % Defines symbol t and s tRange = 0:0.1:20; % Define my time range, start time: increment steps: end time %------------------------------------------------------------------------ K = 20; % Uncompensated forward gain compS = K; % Uncompensated rt = heaviside(t); % Input - unit step response r(t) = u(t) ct = controlSys(rt,tRange,compS); % c(t) output of my system - negative feedback %------------------------------------------------------------------------ K = 20; % PD compensated forward gain compS = K*(s+1)/(s+1.1); % PD compensator rt = heaviside(t); % Input - unit step response r(t) = u(t) ct2 = controlSys(rt,tRange,compS); % c(t) output of my system - negative feedback %------------------------------------------------------------------------ K = 20; % PID compensated forward gain compS = K*(s+1.1)/(s+1.2); % PID compensator rt = heaviside(t); % Input - unit step response r(t) = u(t) ct3 = controlSys(rt,tRange,compS); % c(t) output of my system - negative feedback plot(tRange,real(ct),tRange,real(ct2),tRange,real(ct3),'LineWidth',3) % Plot our output function legend('Uncompensated','PD compensated','PID compensated') ylabel('Output response','fontSize',14) xlabel('Time (t)','fontSize',14) grid on function [ctOut] = controlSys(rt,trange,compS) syms s t; plant = (10*(2*s+5)*(34+6*s+s^2))/((s+7)*(50*s^4+644*s^3+996*s^2-739*s-3559)); gS = compS*plant; hS = 1; rS = laplace(rt); tS = gS / (1+gS*hS); cS = rS*tS; ct = ilaplace(cS,s,t); ctOut = vpa(subs(ct, t, trange));
时间: 2023-08-15 14:53:08 浏览: 181
修改后的代码如下:
clear all; % Clear all memory
clc; % Clear our screen
syms t s; % Defines symbol t and s
tRange = 0:0.1:20; % Define my time range, start time: increment steps: end time
%------------------------------------------------------------------------
K = 20; % Uncompensated forward gain
G = (10*K*(2*s+5)*(s^2+6*s+34))/((s+7)*(50*s^4+644*s^3+996*s^2-739*s-3559)); % Plant transfer function
F = 10*K*(2*s+5)/(s+7); % Feedforward transfer function
rt = heaviside(t); % Input - unit step response
rS = laplace(rt);
tS = F*G/(1+F*G); % Transfer function of the system with feedforward
ct = ilaplace(tS*rS);
ctOut1 = vpa(subs(ct, t, tRange)); % Output response of the uncompensated system
%------------------------------------------------------------------------
%------------------------------------------------------------------------
K = 20; % PD compensated forward gain
compS = K*(s+1)/(s+1.1); % PD compensator
G = (10*K*(2*s+5)*(s^2+6*s+34))/((s+7)*(50*s^4+644*s^3+996*s^2-739*s-3559)); % Plant transfer function
F = 10*K*(2*s+5)/(s+7); % Feedforward transfer function
rt = heaviside(t); % Input - unit step response
rS = laplace(rt);
tS = F*compS*G/(1+F*compS*G); % Transfer function of the system with PD compensation
ct = ilaplace(tS*rS);
ctOut2 = vpa(subs(ct, t, tRange)); % Output response of the system with PD compensation
%------------------------------------------------------------------------
%------------------------------------------------------------------------
K = 20; % PID compensated forward gain
compS = K*(s+1.1)/(s+1.2); % PID compensator
G = (10*K*(2*s+5)*(s^2+6*s+34))/((s+7)*(50*s^4+644*s^3+996*s^2-739*s-3559)); % Plant transfer function
F = 10*K*(2*s+5)/(s+7); % Feedforward transfer function
rt = heaviside(t); % Input - unit step response
rS = laplace(rt);
tS = F*compS*G/(1+F*compS*G); % Transfer function of the system with PID compensation
ct = ilaplace(tS*rS);
ctOut3 = vpa(subs(ct, t, tRange)); % Output response of the system with PID compensation
%------------------------------------------------------------------------
plot(tRange,real(ctOut1),tRange,real(ctOut2),tRange,real(ctOut3),'LineWidth',3) % Plot our output function
legend('Uncompensated','PD compensated','PID compensated')
ylabel('Output response','fontSize',14)
xlabel('Time (t)','fontSize',14)
grid on
阅读全文