<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157690</link>
    <title>MATLAB Central Newsreader - Matrix Manipulation</title>
    <description>Feed for thread: Matrix Manipulation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 14 Oct 2007 21:01:41 -0400</pubDate>
      <title>Matrix Manipulation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157690#396654</link>
      <author>Rob A</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I am working on a control design problem and for some reason&lt;br&gt;
with the combination of using symbols and manipulating a&lt;br&gt;
matrix , a problem arises as I show below in my code.  I&lt;br&gt;
discuss my problem further at the bottom.  It might be&lt;br&gt;
easier to copy and paste this code into notepad or wordpad&lt;br&gt;
so it is more viewable.&lt;br&gt;
&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
% Part A                                                   &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%&lt;br&gt;
%   Given a transfer function of the forward path of a&lt;br&gt;
dynamic system,    %&lt;br&gt;
%   apply the pole placement procedure to design a&lt;br&gt;
state-variable         %&lt;br&gt;
%   controller to satisfy the following specifications:    &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%&lt;br&gt;
%   Tset = 4sec, Overshoot = 15%, Ess caused by a unit step&lt;br&gt;
disturbance &amp;lt;=%&lt;br&gt;
%   0.01                                                   &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
&lt;br&gt;
%First we will specify the numerator and denominator of the&lt;br&gt;
foward T.F.&lt;br&gt;
syms s&lt;br&gt;
num = sym2poly((s + 1)*(s + 2)*(s + 3));&lt;br&gt;
den = [1 2 12 4 10];&lt;br&gt;
%Put the TF in state space form for later use&lt;br&gt;
A= [0 1 0 0; 0 0 1 0; 0 0 0 1; -10 -4 -12 -2];&lt;br&gt;
B = [0;0;0;1];&lt;br&gt;
C = [6 11 6 1];&lt;br&gt;
D = [0];&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
%Since the controlled plant does not have any right-hand&lt;br&gt;
side zeros, other&lt;br&gt;
%complexities are not introduced.&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
&lt;br&gt;
%Having an overshoot of 15% means that zeta should be equal&lt;br&gt;
to about 0.53&lt;br&gt;
zeta = 0.53;&lt;br&gt;
% We also need to satisfy Tset, so we will find our 'a',&lt;br&gt;
%by using the following equation:  a = 4/Tset = 4/4 = 1.&lt;br&gt;
a1 = 1;&lt;br&gt;
%Now we use the following formula to find our first two beta&lt;br&gt;
values:&lt;br&gt;
b1 = sqrtm(1-zeta^2)/zeta&lt;br&gt;
&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
%Since we have a fourth order plant, we will need 2 more non&lt;br&gt;
zero, non&lt;br&gt;
%dominate poles.  We will choose poles 2 and 3 as -4 +/- 1j&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
%So our four roots are:&lt;br&gt;
r1 = -a1 + j*b1;&lt;br&gt;
r2 = -a1 - j*b1;&lt;br&gt;
r3 = -4 + 10j;&lt;br&gt;
r4 = -4 - 10j;&lt;br&gt;
&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
% Now with these roots, we can define the characteristic&lt;br&gt;
polynomial of the&lt;br&gt;
% closed-loop system, Acl = A-BF, as follows:&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
q = sym2poly((s+(-r1))*(s+(-r2))*(s+(-r3))*(s+(-r4)))&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
%Again using Acl = A-BF, we can now solve for the matrix F&lt;br&gt;
which is the&lt;br&gt;
%only unknown the equation&lt;br&gt;
Acl = [0 1 0 0; 0 0 1 0; 0 0 0 1; -q(5) -q(4) -q(3) -q(2)];&lt;br&gt;
F = transpose(B)*(A - Acl)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
% This allows us to obtain the transfer function of the&lt;br&gt;
closed-loop system&lt;br&gt;
% using the formula: Gcl = C(sI-A+BF)^-1(B)&lt;br&gt;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%&lt;br&gt;
G_cl_temp = C*inv(s*eye(4) - A + B*F)*B&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
where....&lt;br&gt;
&amp;gt;&amp;gt; (s*eye(4) - A + B*F)&lt;br&gt;
ans =&lt;br&gt;
[                               s,                         &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-1,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0,                               0]&lt;br&gt;
[                               0,                         &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-1,                               0]&lt;br&gt;
[                               0,                         &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s,                              -1]&lt;br&gt;
[ 7264840089541673/17592186044416, &lt;br&gt;
2291205308377831/8796093022208,&lt;br&gt;
4769592979338611/35184372088832,                           &lt;br&gt;
s+10]&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
My problem is being formed before I even do the inversion in&lt;br&gt;
G_cl_temp as:&lt;br&gt;
&lt;br&gt;
G_cl_temp =&lt;br&gt;
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)&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&lt;br&gt;
I have tried changing the format to short, rat, compact and&lt;br&gt;
some of&lt;br&gt;
the others but it wont compute those fractions.  If I&lt;br&gt;
manually compute&lt;br&gt;
the fraction, round them to a whole number and rebuild the&lt;br&gt;
matrix&lt;br&gt;
before inversion...my answer comes out nicer and nothing in the&lt;br&gt;
numerator is above 11.&lt;br&gt;
&lt;br&gt;
Also, I can't find a way to convert this G_cl_temp into an&lt;br&gt;
actual&lt;br&gt;
ratio of two polynomials without inspection since each&lt;br&gt;
numerator is&lt;br&gt;
separated with the same polynomial denominator.  The&lt;br&gt;
sym2poly command&lt;br&gt;
will not work on G_cl_temp since it is in a summation format.&lt;br&gt;
&lt;br&gt;
The reason for this is that I need to keep changing my&lt;br&gt;
non-dominate&lt;br&gt;
roots so that the steady sate response of a step disturbance&lt;br&gt;
is below&lt;br&gt;
a certain threshold.&lt;br&gt;
&lt;br&gt;
Any suggestions on how to stop getting those huge fractions&lt;br&gt;
in my matrix?&lt;br&gt;
&lt;br&gt;
I appreciate any help.  Thank you.</description>
    </item>
    <item>
      <pubDate>Mon, 15 Oct 2007 15:19:53 -0400</pubDate>
      <title>Re: Matrix Manipulation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157690#396758</link>
      <author>Rob A</author>
      <description>This code can also be pasted into MATLAB or a new m-file to&lt;br&gt;
be ran.  This may help when trying to analyze the problem.&lt;br&gt;
&lt;br&gt;
I would appreciate any suggestions. Thank you</description>
    </item>
    <item>
      <pubDate>Mon, 15 Oct 2007 15:40:54 -0400</pubDate>
      <title>Re: Matrix Manipulation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157690#396770</link>
      <author>Dan Haeg</author>
      <description>&quot;Rob A&quot; &amp;lt;rob.andolina@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;ff00ep$i41$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; This code can also be pasted into MATLAB or a new m-file to&lt;br&gt;
&amp;gt; be ran.  This may help when trying to analyze the problem.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I would appreciate any suggestions. Thank you&lt;br&gt;
&lt;br&gt;
does this help?&lt;br&gt;
&lt;br&gt;
[n,d] = numden(G_cl_temp)&lt;br&gt;
sym2poly(n)&lt;br&gt;
sym2poly(d)</description>
    </item>
    <item>
      <pubDate>Mon, 15 Oct 2007 16:19:29 -0400</pubDate>
      <title>Re: Matrix Manipulation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157690#396784</link>
      <author>Rob A</author>
      <description>&quot;Dan Haeg&quot; &amp;lt;haegd@msoe.edu&amp;gt; wrote in message&lt;br&gt;
&amp;lt;ff01m6$5a7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Rob A&quot; &amp;lt;rob.andolina@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;ff00ep$i41$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; This code can also be pasted into MATLAB or a new m-file to&lt;br&gt;
&amp;gt; &amp;gt; be ran.  This may help when trying to analyze the problem.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I would appreciate any suggestions. Thank you&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; does this help?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [n,d] = numden(G_cl_temp)&lt;br&gt;
&amp;gt; sym2poly(n)&lt;br&gt;
&amp;gt; sym2poly(d)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thank you for the suggestion!  I recently just found out&lt;br&gt;
what I had to do from a classmate.  Don't think I could have&lt;br&gt;
figured this out on my own! The solution is an extension of&lt;br&gt;
yours.  &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
G_cl_temp = C*inv(s*eye(4) - A + B*F)*B&lt;br&gt;
&lt;br&gt;
[num den] = numden(G_cl);&lt;br&gt;
num1 = sym2poly(fliplr(coeffs(num)));&lt;br&gt;
den1 = sym2poly(fliplr(coeffs(den)));&lt;br&gt;
&lt;br&gt;
num2 = num1/den1(1);&lt;br&gt;
den2 = den1/den1(1);&lt;br&gt;
&lt;br&gt;
G_cl_D = tf(num2,den2)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Seems like a very odd way of doing it...but it seems to&lt;br&gt;
work.  Thanks for the help!</description>
    </item>
  </channel>
</rss>

