<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159701</link>
    <title>MATLAB Central Newsreader - rookie Q, visualize function with 3 variables</title>
    <description>Feed for thread: rookie Q, visualize function with 3 variables</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>Thu, 22 Nov 2007 17:37:28 -0500</pubDate>
      <title>Re: rookie Q, visualize function with 3 variables</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159701#402639</link>
      <author>Roger Stafford</author>
      <description>"Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fi3c7m$a7d$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; .......&lt;br&gt;
&amp;gt;   You then define a transformed (rotated) coordinate system (X,Y,Z) in &lt;br&gt;
terms &lt;br&gt;
&amp;gt; of these eigenvectors.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  X = v(1,1)*x+v(2,1)*y+v(3,1)*z;&lt;br&gt;
&amp;gt;  Y = v(1,2)*x+v(2,2)*y+v(3,2)*z;&lt;br&gt;
&amp;gt;  Z = v(1,3)*x+v(2,3)*y+v(3,3)*z;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The X, Y, and Z axes point in the direction of the hyperboloid's principal &lt;br&gt;
axes &lt;br&gt;
&amp;gt; and we have the identity&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  d(1,1)*X^2+d(2,2)*Y^2+d(3,3)*Z^2 =&lt;br&gt;
&amp;gt;  3*X^2+1*Y^2+(-4)*Z^2 =&lt;br&gt;
&amp;gt;  x^2+6*x*y-2*y^2-2*y*z+z^2 = 24&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; or&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  X^2/8 + Y^2/24 - Z^2/6 = 1&lt;br&gt;
&amp;gt; .......&lt;br&gt;
&amp;nbsp;&amp;nbsp;I didn't explain the "identity" in the above paragraph very well.  I should have &lt;br&gt;
said that, since e is symmetric, we have e = v*d*v' and therefore&lt;br&gt;
&lt;br&gt;
24 = x^2+6*x*y-2*y^2-2*y*z+z^2 = [x,y,z]*e*[x;y;z]&lt;br&gt;
= [x,y,z]*v*d*v&amp;#8217;*[x;y;z] = [X,Y,Z]*d*[X;Y;Z]&lt;br&gt;
= 3*X^2+Y^2-4*Z^2&lt;br&gt;
&lt;br&gt;
which is equivalent to&lt;br&gt;
&lt;br&gt;
X^2/8 + Y^2/24 - Z^2/6 = 1&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Thu, 22 Nov 2007 07:48:06 -0500</pubDate>
      <title>Re: rookie Q, visualize function with 3 variables</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159701#402571</link>
      <author>Roger Stafford</author>
      <description>"Bo Pan" &amp;lt;ppyzbp@nottingham.ac.uk&amp;gt; wrote in message &amp;lt;fi2n2a$1nt&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; hi &lt;br&gt;
&amp;gt; i've got a function in the form of &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x^2 + 6xy - 2y^2 - 2yz + z^2 = 24&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; how can i visualize this function in matlab?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks&lt;br&gt;
--------&lt;br&gt;
&amp;nbsp;&amp;nbsp;Perhaps it would help in visualizing this to know that the surface defined by &lt;br&gt;
your equation is that of a one-sheeted hyperboloid.  However its principal &lt;br&gt;
axes are not aligned with your x,y,z coordinate axes.  You can determine &lt;br&gt;
what these principal axes are as follows.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;From the coefficients in the quadratic expression define the matrix&lt;br&gt;
&lt;br&gt;
&amp;nbsp;e = [ 1  ,   6/2 ,  0/2;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6/2 ,   -2  , -2/2;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0/2 , -2/2 ,   1  ];&lt;br&gt;
&lt;br&gt;
That is, the coefficients of x^2, y^2, and z^2 are its diagonal elements and &lt;br&gt;
half those of x*y, y*z, and x*z (which isn&amp;#8217;t there in this case) are its &lt;br&gt;
symmetrical off-diagonals.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Then find the eigenvectors and eigenvalues of e.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;[v,d] = eig(e);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;v =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;0.80178372573727  -0.31622776601684   0.50709255283711&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;0.53452248382485  -0.00000000000000  -0.84515425472852&lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.26726124191242  -0.94868329805051  -0.16903085094570&lt;br&gt;
&lt;br&gt;
&amp;nbsp;diag(d) =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;3.00000000000000&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;1.00000000000000&lt;br&gt;
&amp;nbsp;&amp;nbsp;-4.00000000000000&lt;br&gt;
&lt;br&gt;
The columns of v are the eigenvectors and they constitute the three principal &lt;br&gt;
directions of the hyperboloid.  The diagonals of d are the eigenvalues (and in &lt;br&gt;
this case are all integers.)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;You then define a transformed (rotated) coordinate system (X,Y,Z) in terms &lt;br&gt;
of these eigenvectors.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;X = v(1,1)*x+v(2,1)*y+v(3,1)*z;&lt;br&gt;
&amp;nbsp;Y = v(1,2)*x+v(2,2)*y+v(3,2)*z;&lt;br&gt;
&amp;nbsp;Z = v(1,3)*x+v(2,3)*y+v(3,3)*z;&lt;br&gt;
&lt;br&gt;
The X, Y, and Z axes point in the direction of the hyperboloid&amp;#8217;s principal axes &lt;br&gt;
and we have the identity&lt;br&gt;
&lt;br&gt;
&amp;nbsp;d(1,1)*X^2+d(2,2)*Y^2+d(3,3)*Z^2 =&lt;br&gt;
&amp;nbsp;3*X^2+1*Y^2+(-4)*Z^2 =&lt;br&gt;
&amp;nbsp;x^2+6*x*y-2*y^2-2*y*z+z^2 = 24&lt;br&gt;
&lt;br&gt;
or&lt;br&gt;
&lt;br&gt;
&amp;nbsp;X^2/8 + Y^2/24 - Z^2/6 = 1&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;This makes it evident that we are dealing with a one-sheeted hyperboloid &lt;br&gt;
with the above principal directions.  Every cross section orthogonal to the Z &lt;br&gt;
axis - that is, having a constant value of Z - will be an X,Y ellipse:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;X^2/8 + Y^2/24 = 1 + Z^2/6&lt;br&gt;
&lt;br&gt;
Similarly, every cross section containing the Z-axis will be a hyperbola.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Presumably you can now use the new transformed X,Y,Z coordinates to &lt;br&gt;
generate a surface which matlab can display using a function like 'surf'.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Thu, 22 Nov 2007 01:46:50 -0500</pubDate>
      <title>rookie Q, visualize function with 3 variables</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159701#402557</link>
      <author>Bo Pan</author>
      <description>hi &lt;br&gt;
i've got a function in the form of &lt;br&gt;
&lt;br&gt;
x^2 + 6xy - 2y^2 - 2yz + z^2 = 24&lt;br&gt;
&lt;br&gt;
how can i visualize this function in matlab?&lt;br&gt;
&lt;br&gt;
thanks&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
