Thread Subject: Matrix Manipulation

Subject: Matrix Manipulation

From: Rob A

Date: 14 Oct, 2007 21:01:41

Message: 1 of 4

Hi,

I am working on a control design problem and for some reason
with the combination of using symbols and manipulating a
matrix , a problem arises as I show below in my code. I
discuss my problem further at the bottom. It might be
easier to copy and paste this code into notepad or wordpad
so it is more viewable.

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% Part A
              %
% Given a transfer function of the forward path of a
dynamic system, %
% apply the pole placement procedure to design a
state-variable %
% controller to satisfy the following specifications:
              %
% Tset = 4sec, Overshoot = 15%, Ess caused by a unit step
disturbance <=%
% 0.01
              %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

%First we will specify the numerator and denominator of the
foward T.F.
syms s
num = sym2poly((s + 1)*(s + 2)*(s + 3));
den = [1 2 12 4 10];
%Put the TF in state space form for later use
A= [0 1 0 0; 0 0 1 0; 0 0 0 1; -10 -4 -12 -2];
B = [0;0;0;1];
C = [6 11 6 1];
D = [0];


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%Since the controlled plant does not have any right-hand
side zeros, other
%complexities are not introduced.
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

%Having an overshoot of 15% means that zeta should be equal
to about 0.53
zeta = 0.53;
% We also need to satisfy Tset, so we will find our 'a',
%by using the following equation: a = 4/Tset = 4/4 = 1.
a1 = 1;
%Now we use the following formula to find our first two beta
values:
b1 = sqrtm(1-zeta^2)/zeta

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%Since we have a fourth order plant, we will need 2 more non
zero, non
%dominate poles. We will choose poles 2 and 3 as -4 +/- 1j
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%So our four roots are:
r1 = -a1 + j*b1;
r2 = -a1 - j*b1;
r3 = -4 + 10j;
r4 = -4 - 10j;

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% Now with these roots, we can define the characteristic
polynomial of the
% closed-loop system, Acl = A-BF, as follows:
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
q = sym2poly((s+(-r1))*(s+(-r2))*(s+(-r3))*(s+(-r4)))


%Again using Acl = A-BF, we can now solve for the matrix F
which is the
%only unknown the equation
Acl = [0 1 0 0; 0 0 1 0; 0 0 0 1; -q(5) -q(4) -q(3) -q(2)];
F = transpose(B)*(A - Acl)


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% This allows us to obtain the transfer function of the
closed-loop system
% using the formula: Gcl = C(sI-A+BF)^-1(B)
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
G_cl_temp = C*inv(s*eye(4) - A + B*F)*B


where....
>> (s*eye(4) - A + B*F)
ans =
[ s,
    -1,
                          0, 0]
[ 0,
     s,
                         -1, 0]
[ 0,
     0,
                          s, -1]
[ 7264840089541673/17592186044416,
2291205308377831/8796093022208,
4769592979338611/35184372088832,
s+10]
>>


My problem is being formed before I even do the inversion in
G_cl_temp as:

G_cl_temp =
211106232532992/(35184372088832*s^4+351843720888320*s^3+4769592979338611*s^2+9164821233511324*s+14529680179083346)+387028092977152*s/(35184372088832*s^4+351843720888320*s^3+4769592979338611*s^2+9164821233511324*s+14529680179083346)+211106232532992*s^2/(35184372088832*s^4+351843720888320*s^3+4769592979338611*s^2+9164821233511324*s+14529680179083346)+35184372088832*s^3/(35184372088832*s^4+351843720888320*s^3+4769592979338611*s^2+9164821233511324*s+14529680179083346)
>>

I have tried changing the format to short, rat, compact and
some of
the others but it wont compute those fractions. If I
manually compute
the fraction, round them to a whole number and rebuild the
matrix
before inversion...my answer comes out nicer and nothing in the
numerator is above 11.

Also, I can't find a way to convert this G_cl_temp into an
actual
ratio of two polynomials without inspection since each
numerator is
separated with the same polynomial denominator. The
sym2poly command
will not work on G_cl_temp since it is in a summation format.

The reason for this is that I need to keep changing my
non-dominate
roots so that the steady sate response of a step disturbance
is below
a certain threshold.

Any suggestions on how to stop getting those huge fractions
in my matrix?

I appreciate any help. Thank you.



Subject: Matrix Manipulation

From: Rob A

Date: 15 Oct, 2007 15:19:53

Message: 2 of 4

This code can also be pasted into MATLAB or a new m-file to
be ran. This may help when trying to analyze the problem.

I would appreciate any suggestions. Thank you

Subject: Matrix Manipulation

From: Dan Haeg

Date: 15 Oct, 2007 15:40:54

Message: 3 of 4

"Rob A" <rob.andolina@gmail.com> wrote in message
<ff00ep$i41$1@fred.mathworks.com>...
> This code can also be pasted into MATLAB or a new m-file to
> be ran. This may help when trying to analyze the problem.
>
> I would appreciate any suggestions. Thank you

does this help?

[n,d] = numden(G_cl_temp)
sym2poly(n)
sym2poly(d)

Subject: Matrix Manipulation

From: Rob A

Date: 15 Oct, 2007 16:19:29

Message: 4 of 4

"Dan Haeg" <haegd@msoe.edu> wrote in message
<ff01m6$5a7$1@fred.mathworks.com>...
> "Rob A" <rob.andolina@gmail.com> wrote in message
> <ff00ep$i41$1@fred.mathworks.com>...
> > This code can also be pasted into MATLAB or a new m-file to
> > be ran. This may help when trying to analyze the problem.
> >
> > I would appreciate any suggestions. Thank you
>
> does this help?
>
> [n,d] = numden(G_cl_temp)
> sym2poly(n)
> sym2poly(d)




Thank you for the suggestion! I recently just found out
what I had to do from a classmate. Don't think I could have
figured this out on my own! The solution is an extension of
yours.


G_cl_temp = C*inv(s*eye(4) - A + B*F)*B

[num den] = numden(G_cl);
num1 = sym2poly(fliplr(coeffs(num)));
den1 = sym2poly(fliplr(coeffs(den)));

num2 = num1/den1(1);
den2 = den1/den1(1);

G_cl_D = tf(num2,den2)



Seems like a very odd way of doing it...but it seems to
work. Thanks for the help!




Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
matrix Rob A 14 Oct, 2007 17:05:07
controls Rob A 14 Oct, 2007 17:05:07
problem Rob A 14 Oct, 2007 17:05:07
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com