Why won't my rlocus function work

6 次查看(过去 30 天)
John Smith
John Smith 2016-11-3
close all; clc; clear
% Q1
A=[0 1 0 0; -4 -56 4 56; 0 0 0 1; 31.25 437.5 -62.5 -437.5];
B=[0 0; 1 0; 0 0; 0 31.25];
C=[1 0 -1 0];
D=[0 0];
[n1,d1]=ss2tf(A,B,C,D,1) % nominator and denominator of P
[n2,d2]=ss2tf(A,B,C,D,2) % nominator and denominator of F
P=tf(n1,d1) % transfer function of P=Y/U
F=tf(n2,d2) % transfer function of F=Y/W
% Q2
D=F/P % transfer function of D
Dmin=minreal(D) % simplified D
% Q3
P_poles=pole(P) % poles of plant P
%Q4
pole_far=P_poles(1)
s=tf('s');
P_s=minreal(((pole_far-s)/(pole_far))*P)
%Q5
rlocus(P_s)
%Q6
z1=-1+(-4)^0.5;
z2=-1-(-4)^0.5;
p1=-20;
p2=-50;
N=(P_s*(s-z1)*(s-z2))/((s-p1)*(s-p2));
figure
rlocus(N)
axis([-4 0.5 -6 6])
%Q7
[k,poles]=rlocfind(N);
%Q8
C=k*(s-z1)*(s-z2)/((s-p1)*(s-p2));
H=Dmin*feedback(P,C);
step(0.2*H)
if true
% code
end
Also H isnt producing anything, where have I gone wrong?

回答(1 个)

Star Strider
Star Strider 2016-11-3
The numerator of ‘N’ is complex, although the imaginary parts are vanishingly small (on the order of approximation error), so you can safely delete them. Add the ‘N.numerator’ assignment to your code just after the initial ‘N’ assignment, and it works (at least as far as I’ve tested it):
N=(P_s*(s-z1)*(s-z2))/((s-p1)*(s-p2));
N.numerator = real(N.numerator{:})); % <— ADD THIS ASSIGNMENT

类别

Help CenterFile Exchange 中查找有关 Classical Control Design 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by