A First Course in FUZZY and NEURAL CONTROL

(singke) #1
28 CHAPTER 2. MATHEMATICAL MODELS IN CONTROL

we can easily manipulate the transfer function inMatlabfor various numerical
values ofKP,KD,andKI. To convolve the polynomials in the denominator of
the transfer function, we use a special function calledpolyadd.mthat is added
to the library. The functionpolyadd.mis not in theMatlabtoolbox. This
function will add two polynomials even if they do not have the same length. To
usepolyadd.minMatlab,enterpolyadd(poly1, poly2). Add the following code
to your work folder.


function[poly]=polyadd(poly1,poly2)
%Copyright 1996 Justin Shriver
%polyadd(poly1,poly2) adds two polynomials possibly of unequal length
if length(poly1)<length(poly2)
short=poly1;
long=poly2;
else
short=poly2;
long=poly1;
end
mz=length(long)-length(short);
if mz> 0
poly=[zeros(1,mz),short]+long;
else
poly=long+short;
end

It is very convenient to develop controllers using the Simulink features of
Matlab. For the inverted pendulum problem, the simulation diagram using
Simulink is shown in Figure 2.9. Parameters for the PID controller can be
varied to examine how the system will perform.


Figure 2.9. Simulink model for inverted pendulum problem
Free download pdf