Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Plotting complex numbers

Subject: Plotting complex numbers

From: Sarah Coleman

Date: 19 Apr, 2012 00:50:39

Message: 1 of 3

Hi guys, I want to plot the following expression of 'Z' with respect to 't':

t = linspace(0,10,1000);

Z = 1/55 - ((3 - 1i*sqrt(11))/330)*exp(-0.5*(11 - 3*1i*sqrt(11))*t) - ((3 + 1i*sqrt(11))/330)*exp(-0.5*(11 + 3*1i*sqrt(11))*t)+(4/55)*heaviside(t-1) - ((2*(3 - 1i*sqrt(11)))/165)*exp(0.5*(11 - 3*1i*sqrt(11))*(1-t))*heaviside(t-1) - ((2*(3 + 1i*sqrt(11)))/165)*exp(0.5*(11 + 3*1i*sqrt(11))*(1-t))*heaviside(t-1) - (1/11)*heaviside(t-3) + ((3 - 1i*sqrt(11))/66)*exp(0.5*(11 - 3*1i*sqrt(11))*(3-t))*heaviside(t-3)
+ ((3 + 1i*sqrt(11))/66)*exp(0.5*(11 + 3*1i*sqrt(11))*(3-t))*heaviside(t-3);

plot(t,Z);

Thanks

Subject: Plotting complex numbers

From: TideMan

Date: 19 Apr, 2012 03:50:29

Message: 2 of 3

On Thursday, April 19, 2012 12:50:39 PM UTC+12, Sarah Coleman wrote:
> Hi guys, I want to plot the following expression of 'Z' with respect to 't':
>
> t = linspace(0,10,1000);
>
> Z = 1/55 - ((3 - 1i*sqrt(11))/330)*exp(-0.5*(11 - 3*1i*sqrt(11))*t) - ((3 + 1i*sqrt(11))/330)*exp(-0.5*(11 + 3*1i*sqrt(11))*t)+(4/55)*heaviside(t-1) - ((2*(3 - 1i*sqrt(11)))/165)*exp(0.5*(11 - 3*1i*sqrt(11))*(1-t))*heaviside(t-1) - ((2*(3 + 1i*sqrt(11)))/165)*exp(0.5*(11 + 3*1i*sqrt(11))*(1-t))*heaviside(t-1) - (1/11)*heaviside(t-3) + ((3 - 1i*sqrt(11))/66)*exp(0.5*(11 - 3*1i*sqrt(11))*(3-t))*heaviside(t-3)
> + ((3 + 1i*sqrt(11))/66)*exp(0.5*(11 + 3*1i*sqrt(11))*(3-t))*heaviside(t-3);
>
> plot(t,Z);
>
> Thanks

So, what you did is plot the real part.
To get the imaginary part:
plot(t,imag(Z))

Subject: Plotting complex numbers

From: Roger Stafford

Date: 19 Apr, 2012 06:43:22

Message: 3 of 3

"Sarah Coleman" wrote in message <jmnngv$mol$1@newscl01ah.mathworks.com>...
> Hi guys, I want to plot the following expression of 'Z' with respect to 't':
>
> t = linspace(0,10,1000);
> Z = 1/55 - ((3 - 1i*sqrt(11))/330)*exp(-0.5*(11 - 3*1i*sqrt(11))*t) .....
- - - - - - - - - -
  Use 'plot3' to display both the real and imaginary parts of Z along the x and y axes.

 Zr - real(Z);
 Zi = imag(Z);
 plot3(Zr,Zi,t)

Note: I believe you need a few ".*" in place of "*" in your expression for Z to make it a valid vector, as for example, at the end:

 ..... + 3*1i*sqrt(11))*(3-t)).*heaviside(t-3);

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

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.

Contact us