<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169009</link>
    <title>MATLAB Central Newsreader - variable help</title>
    <description>Feed for thread: variable help</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The 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>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 09 May 2008 16:05:05 -0400</pubDate>
      <title>variable help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169009#431268</link>
      <author>Katie </author>
      <description>This is my first time using MATLAB,&lt;br&gt;
I am using this formula to compute sign patterns of 4x4 &lt;br&gt;
nilpotent matrices;&lt;br&gt;
A(n+1)=P*A(n)*inv(P) for n=1,2,3,4, where P is a random &lt;br&gt;
matrix and A(1) is the 4x4 jordan. (This formula can be &lt;br&gt;
repeated up to n=4 before sign patterns are duplicated, n &lt;br&gt;
is the number of times that the random matrix (P) can be &lt;br&gt;
used- just a subscript to define the variables). so what I &lt;br&gt;
did was:&lt;br&gt;
A2=P*A1*inv(P)  &lt;br&gt;
A3=P*A2*inv(P)&lt;br&gt;
A4=P*A3*inv(P)&lt;br&gt;
A5=P*A4*inv(P)&lt;br&gt;
&lt;br&gt;
I want to loop this until all the possible sign patterns &lt;br&gt;
for nilpotent matrices are obtained, changing the random &lt;br&gt;
matrix every 4 times. BUT obviously if I were to loop this &lt;br&gt;
set of equations, for each new P the variables would just &lt;br&gt;
be replaced each time since they are named the same. I have &lt;br&gt;
tried using A(i) or A(n) like in the original equation, but &lt;br&gt;
it is read as multiplication. How do I solve this problem? &lt;br&gt;
or create some sort of subscript system so that the &lt;br&gt;
subscript of the variables change each time. &lt;br&gt;
THANK YOU! &lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 09 May 2008 16:30:18 -0400</pubDate>
      <title>Re: variable help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169009#431273</link>
      <author>someone </author>
      <description>"Katie " &amp;lt;kmcdon03@uoguelph.ca&amp;gt; wrote in message &lt;br&gt;
&amp;lt;g01snh$q9j$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; This is my first time using MATLAB,&lt;br&gt;
&amp;gt; I am using this formula to compute sign patterns of 4x4 &lt;br&gt;
&amp;gt; nilpotent matrices;&lt;br&gt;
&amp;gt; A(n+1)=P*A(n)*inv(P) for n=1,2,3,4, where P is a random &lt;br&gt;
&amp;gt; matrix and A(1) is the 4x4 jordan. (This formula can be &lt;br&gt;
&amp;gt; repeated up to n=4 before sign patterns are duplicated, n &lt;br&gt;
&amp;gt; is the number of times that the random matrix (P) can be &lt;br&gt;
&amp;gt; used- just a subscript to define the variables). so what &lt;br&gt;
I &lt;br&gt;
&amp;gt; did was:&lt;br&gt;
&amp;gt; A2=P*A1*inv(P)  &lt;br&gt;
&amp;gt; A3=P*A2*inv(P)&lt;br&gt;
&amp;gt; A4=P*A3*inv(P)&lt;br&gt;
&amp;gt; A5=P*A4*inv(P)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want to loop this until all the possible sign patterns &lt;br&gt;
&amp;gt; for nilpotent matrices are obtained, changing the random &lt;br&gt;
&amp;gt; matrix every 4 times. BUT obviously if I were to loop &lt;br&gt;
this &lt;br&gt;
&amp;gt; set of equations, for each new P the variables would just &lt;br&gt;
&amp;gt; be replaced each time since they are named the same. I &lt;br&gt;
have &lt;br&gt;
&amp;gt; tried using A(i) or A(n) like in the original equation, &lt;br&gt;
but &lt;br&gt;
&amp;gt; it is read as multiplication.&lt;br&gt;
&lt;br&gt;
I'm not sure what "read as multiplication" means.  If you &lt;br&gt;
want element-by-element multiplication instead of matrix &lt;br&gt;
multiplication replace "*" with ".*" in the above.&lt;br&gt;
&lt;br&gt;
&amp;gt; How do I solve this problem? &lt;br&gt;
&amp;gt; or create some sort of subscript system so that the &lt;br&gt;
&amp;gt; subscript of the variables change each time.&lt;br&gt;
&lt;br&gt;
The short answer is don't do this!  Use cell arrays instead.&lt;br&gt;
&lt;br&gt;
You may want to see Q 4.6 in the MATLAB FAQ at:&lt;br&gt;
&lt;br&gt;
http:/matlabwiki.mathworks.com/MATLAB_FAQ&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;gt; THANK YOU! &lt;br&gt;
&lt;br&gt;
There is probably some way to use the MATLAB "sum" command &lt;br&gt;
(without using a loop) to do what you want.  Try&lt;br&gt;
&lt;br&gt;
doc sum&lt;br&gt;
&lt;br&gt;
at the MATLAB command promt.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 09 May 2008 19:39:03 -0400</pubDate>
      <title>Re: variable help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169009#431290</link>
      <author>Roger Stafford</author>
      <description>"Katie " &amp;lt;kmcdon03@uoguelph.ca&amp;gt; wrote in message &amp;lt;g01snh$q9j&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; This is my first time using MATLAB,&lt;br&gt;
&amp;gt; I am using this formula to compute sign patterns of 4x4 &lt;br&gt;
&amp;gt; nilpotent matrices;&lt;br&gt;
&amp;gt; A(n+1)=P*A(n)*inv(P) for n=1,2,3,4, where P is a random &lt;br&gt;
&amp;gt; matrix and A(1) is the 4x4 jordan. (This formula can be &lt;br&gt;
&amp;gt; repeated up to n=4 before sign patterns are duplicated, n &lt;br&gt;
&amp;gt; is the number of times that the random matrix (P) can be &lt;br&gt;
&amp;gt; used- just a subscript to define the variables). so what I &lt;br&gt;
&amp;gt; did was:&lt;br&gt;
&amp;gt; A2=P*A1*inv(P)  &lt;br&gt;
&amp;gt; A3=P*A2*inv(P)&lt;br&gt;
&amp;gt; A4=P*A3*inv(P)&lt;br&gt;
&amp;gt; A5=P*A4*inv(P)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want to loop this until all the possible sign patterns &lt;br&gt;
&amp;gt; for nilpotent matrices are obtained, changing the random &lt;br&gt;
&amp;gt; matrix every 4 times. BUT obviously if I were to loop this &lt;br&gt;
&amp;gt; set of equations, for each new P the variables would just &lt;br&gt;
&amp;gt; be replaced each time since they are named the same. I have &lt;br&gt;
&amp;gt; tried using A(i) or A(n) like in the original equation, but &lt;br&gt;
&amp;gt; it is read as multiplication. How do I solve this problem? &lt;br&gt;
&amp;gt; or create some sort of subscript system so that the &lt;br&gt;
&amp;gt; subscript of the variables change each time. &lt;br&gt;
&amp;gt; THANK YOU! &lt;br&gt;
-----------&lt;br&gt;
&amp;nbsp;&amp;nbsp;What kind of "sign pattern" are you looking for?  Granted that each of the &lt;br&gt;
matrices A2, A3, A4, A5, etc. you generate from a given P will be nilpotent if &lt;br&gt;
A1 is, but I don't seen any repeating patterns of signs in them.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;However, to answer your question, you could always store your results in a &lt;br&gt;
four-dimensional array as follows.  Let nilpotent A and the number of &lt;br&gt;
repetitions N be given.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;P = randn(4,4,N);&lt;br&gt;
&amp;nbsp;M = zeros(4,4,4,N);&lt;br&gt;
&amp;nbsp;for k = 1:N&lt;br&gt;
&amp;nbsp;&amp;nbsp;p = P(:,:,k);&lt;br&gt;
&amp;nbsp;&amp;nbsp;for m = 1:4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;A = p*A*inv(p);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;M(:,:,m,k) = A;&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Alternatively you could place each 4 x 4 matrix A in a 16 x 1 arrangement in &lt;br&gt;
a three-dimensional 16 x 4 x N array.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;P = randn(4,4,N);&lt;br&gt;
&amp;nbsp;M = zeros(16,4,N);&lt;br&gt;
&amp;nbsp;for k = 1:N&lt;br&gt;
&amp;nbsp;&amp;nbsp;p = P(:,:,k);&lt;br&gt;
&amp;nbsp;&amp;nbsp;for m = 1:4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;A = p*A*inv(p);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;M(:,m,k) = A(:);&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Note that you should not do this for too large a value of N, because &lt;br&gt;
cumulative round-off errors will gradually erode the condition of A being &lt;br&gt;
nilpotent.  That is, the size of elements in A^4 would gradually increase in &lt;br&gt;
size due to accumulating round-off errors.  Note also that by chance some of &lt;br&gt;
the p matrices may be nearly singular which will no doubt make the round-&lt;br&gt;
off error situation worse.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
