i can't plot this function in matlab

2 visualizaciones (últimos 30 días)
Nadia Khamassi
Nadia Khamassi el 6 de Oct. de 2021
Respondida: Star Strider el 6 de Oct. de 2021
Hi all I'm new to Matlab so some help would be greatly appreciated.
Given the function f(t)=j/2* (exp(-j*2*pi*t)-exp(j*2*pi*t))
I have this code below to plot the function but for some reason I'm getting a straight line. not sure where my error is.
t=-1:0.01:1;
a=1j*0.5;
theta=1j*2*pi*t;
f=a.*(exp(-(theta))-exp(theta));
plot(real(f),imag(f));
axis equal, grid on;

Respuestas (2)

KSSV
KSSV el 6 de Oct. de 2021
You see, your f is not a complex number. As you are plotting it as complex, you are getting a striaght line.
t=-1:0.01:1;
a=1j*0.5;
theta=1j*2*pi*t;
f=a.*(exp(-(theta))-exp(theta));
plot(f);
% axis equal
grid on;

Star Strider
Star Strider el 6 de Oct. de 2021
The code is correct except for the plot arguments. In the plot, it is necessary to plot the real and imaginary parts aginst ‘t’ instead of each other.
t=-1:0.01:1;
a=1j*0.5;
theta=1j*2*pi*t;
f=a.*(exp(-(theta))-exp(theta));
plot(t,real(f), t,imag(f));
axis equal, grid on
.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by