<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172039</link>
    <title>MATLAB Central Newsreader - How do I get Real and imaginary parts of a symbolic expression?</title>
    <description>Feed for thread: How do I get Real and imaginary parts of a symbolic expression?</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>Fri, 04 Jul 2008 11:42:01 -0400</pubDate>
      <title>How do I get Real and imaginary parts of a symbolic expression?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172039#441174</link>
      <author>Emeka Obe</author>
      <description>Dear All,&lt;br&gt;
&lt;br&gt;
I experience a problem getting the real and imaginary parts &lt;br&gt;
of a complex expression in symbolic form.&lt;br&gt;
For example I have this code and will like to know how to &lt;br&gt;
get the real and imaginary parts:&lt;br&gt;
&lt;br&gt;
clear; clc;&lt;br&gt;
syms x y n&lt;br&gt;
z=n*cos(x)+i*y*sin(x);&lt;br&gt;
r = real(z);&lt;br&gt;
m = imag(z);&lt;br&gt;
&lt;br&gt;
The expressions I expected to get were:&lt;br&gt;
r = n*cos(x) and&lt;br&gt;
m = y*sin(x).&lt;br&gt;
&lt;br&gt;
But I got instead :&lt;br&gt;
r =&lt;br&gt;
&amp;nbsp;&lt;br&gt;
1/2*n*cos(x)+1/2*i*y*sin(x)+1/2*conj(n*cos(x)+i*y*sin(x))&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;nbsp;and&lt;br&gt;
&lt;br&gt;
m =&lt;br&gt;
&amp;nbsp;&lt;br&gt;
-1/2*i*(n*cos(x)+i*y*sin(x)-conj(n*cos(x)+i*y*sin(x)))&lt;br&gt;
&lt;br&gt;
Though these are correct, I cannot I cannot simplify them &lt;br&gt;
to obtain the answers I listed above. Can anyone help me &lt;br&gt;
out of this?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
&lt;br&gt;
ES</description>
    </item>
  </channel>
</rss>

