

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


num=[ , , ]; % Define the polynomials of the open loop transfer function den=[ , , , ]; rlocus(num,den); % Plot root locus. Matlab chooses a set of K automatically or [r,k]=rlocus(num,den); % No plot is generated. r contains all roots, k is the K % series used by the function rlocus() plot(r,’x’); % Plot the root locus using a symbol x
You can also select your own K series.
K=0:0.1:100; rlocus(num,den,K); % Note: The locus will consist of dots, not lines if you ks=50; % specify your own K. or r=rlocus(num,den,ks); % Store the roots in r
hold on; % Hold this figure K=[10, 20, 30]; % Specify your special K values rlocus(num,den,K); % The locus consists of dots overlaid on the above figure title(‘Your figure title’); hold off;
Leave the root locus plot figure window open and active!
[k,poles]=rlocfind(num,den); % You use mouse to select poles. k and poles will % contain the gain value and the poles you selected.
If you know a set of poles, define them in a vector:
p=[p1, p2, .., pm]; [k, poles]=rlocfind(num,den,p); % You get the same solution as above without mouse
K=logspace[-3,3,100]; % Generate 100 points of K in the range 10-3^ to 10+ % Logarithmically spaced r=rlocus(num,den,K); loglog(K, abs(r(1,:)), K, abs(r(2,:)), ..., K, abs(r(n,:)) );
semilogx(K, angle(r(1,:)), K, angle(r(2,:)), ..., K, angle(r(n,:)) );
num=[ , , ]; % Define the polynomials of the open loop transfer function den=[ , , , ]; bode(num,den); % Generate a Bode plot, Mag in dB.
or [mag,phase,w]=bode(num,den); % No plot is generated fr=w/(2*pi); % fr = frequency in Hz subplot(211); loglog(fr,mag); % Plot magnitude in log-log scale xlabel(‘Frequency in Hz’); ylabel(‘Magnitude’); title(‘Yours’); subplot(212); semilogx(fr,phase); % Plot phase in semi-log scale xlabel(‘Frequency in Hz’); ylabel(‘Phase in degree);
You can also select your own w series.
w=logspace(-2,2,100); bode(num,den,w);
w=logspace(-2,2,100); % Specify your special ω values nyquist(num,den,w); title(‘Your title’); xlabel(‘Real part of G(s)’); ylabel(‘Imaginary part of G(s)’);
Matlab has a function called lsim() for time domain simulations. This feature will be needed in your design project. Assume that the output of a system is given by the following transfer functions,
Y s G s U s G s W s num s den s
U s numd s dend s
( ) ( ) ( ) (^) d ( ) ( ) W s