Docsity

A Matlab Tutorial-Control Design Commands | MEEG 311, Study Guides, Projects, Research of Advanced Control Systems

Toggle sidebar
bg1
University of Delaware
Department of Mechanical Engineering
-1-
A Matlab Tutorial – Control Design Commands
1. Use Matlab to create Root-locus
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
2. Overlay plots of special K values on the complete locus
rlocus(num,den); % This gives the complete continuous locus from K=0 to ∞.
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;
3. Find gain values K from the root locus
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
4. Gain plots (closed loop pole magnitude vs. K) and Phase plots (closed loop pole
phase vs. K)
K=logspace[-3,3,100]; % Generate 100 points of K in the range 10-3 to 10+3
% Logarithmically spaced
r=rlocus(num,den,K);
loglog(K, abs(r(1,:)), K, abs(r(2,:)), ..., K, abs(r(n,:)) );
pf3

Partial preview of the text

Download A Matlab Tutorial-Control Design Commands | MEEG 311 and more Study Guides, Projects, Research Advanced Control Systems in PDF only on Docsity!

University of Delaware

Department of Mechanical Engineering

A Matlab Tutorial – Control Design Commands

1. Use Matlab to create Root-locus

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

2. Overlay plots of special K values on the complete locus

rlocus(num,den); % This gives the complete continuous locus from K=0 to ∞.

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;

3. Find gain values K from the root locus

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

4. Gain plots (closed loop pole magnitude vs. K) and Phase plots (closed loop pole

phase vs. K)

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,:)) );

5. Bode Plots

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);

6. Nyquist Plots

nyquist(num,den); % This gives a continuous Nyquist plot for ω=-∞ to ∞.

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)’);

7. Time Domain Simulations

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