修改下列代码,利用下面函数,使其满足:负统一反馈系统具有前馈函数,定义为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 11:53:08 浏览: 45
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*(10*(2*s+5)*(s^2+6*s+34))/((s+7)*(50*s^4+644*s^3+996*s^2-739*s-3559)); % Feedforward function
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));
end