A negative unity feedback system has a feedforward function defined as G(s) = 10K * (2s + 5) * (s^2 + 6s + 34) / ((s + 7) * (50s^4 + 644s^3 + 996s^2 - 739s - 3559)) The input to the system is r(t) = u(t). You will need to provide a Matlab code to find the gain K and closed loop pole locations for a 41% overshoot, motivate if a second order approximation is acceptable?
时间: 2024-03-15 18:46:17 浏览: 143
以下是 Matlab 代码,用于计算给定反馈系统的增益 K 和闭环极点位置,以实现 41% 超调量,并检查是否可以采用二阶近似:
```
% Define the feedforward function G(s)
num = 10 * [2, 5, 1, 34];
den = conv([1, 7], [50, 644, 996, -739, -3559]);
G = tf(num, den);
% Define the input function r(t)
t = 0:0.01:10;
r = ones(size(t));
% Calculate the gain K for a 41% overshoot
zeta = 0.41; % Define the desired damping ratio
omega_n = 4 / (zeta * 10); % Calculate the natural frequency
p = roots([1, 2*zeta*omega_n, omega_n^2]); % Calculate the desired poles
K = abs((p(3)^2 - den(5)*p(3) + (den(4)-p(3)*den(5))*p(2) + (den(3)-p(2)*den(5)-p(3)*den(4))*p(1)) / (num(1)*(p(1)-7)));
% Calculate the closed loop transfer function T(s)
T = feedback(K * G, 1);
% Plot the step response of the closed loop system
step(T);
% Calculate the closed loop pole locations
p = pole(T);
disp(p);
% Check if a second order approximation is acceptable
z = zero(G);
wn = sqrt(abs(z(1))^2 + abs(z(2))^2); % Calculate the natural frequency
zeta = (-real(z(1))*real(z(2))) / (wn*abs(z(1)+z(2))); % Calculate the damping ratio
if zeta >= 0.5
disp("A second order approximation is acceptable.");
else
disp("A second order approximation is not acceptable.");
end
```
输出将包括:
1. 绘制的闭环系统的阶跃响应图。
2. 闭环系统的极点位置。
3. 二阶近似是否可行的结果。
需要注意的是,这个代码中的增益计算公式是基于传递函数的系数,如果传递函数不是此形式,需要修改相应的增益计算公式。
阅读全文