A negative unity feedback system has a feedforward function defined as G(s) = 250 * (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 15:45:56 浏览: 59
A*寻路2D示例Unity工程PathFinding
Sure, I can help you with that! Here's the Matlab code to find the gain K and closed loop pole locations for a 41% overshoot:
```
% Define the feedforward function G(s)
num = [250, 1250, 4250, 8500];
den = [50, 694, 1690, -739, -3559];
G = tf(num, den);
% Define the input function r(t)
t = 0:0.01:10;
r = ones(size(t));
% Calculate the closed loop transfer function T(s)
K = 1 / (1 - 0.41); % Calculate the gain K for a 41% overshoot
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
```
In this code, we define the feedforward function `G(s)` using its numerator and denominator coefficients. We also define the input function `r(t)` as a unit step function.
We then use the `feedback` function to calculate the closed loop transfer function `T(s)` for a gain `K` that results in a 41% overshoot. We plot the step response of the closed loop system to visualize its behavior.
Finally, we use the `pole` function to calculate the closed loop pole locations, and we check if a second order approximation is acceptable by calculating the system's natural frequency `wn` and damping ratio `zeta`. If `zeta >= 0.5`, then a second order approximation is acceptable.
I hope this helps! Let me know if you have any further questions.
阅读全文