i can't plot this function in matlab

2 次查看(过去 30 天)
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;

回答(2 个)

KSSV
KSSV 2021-10-6
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 2021-10-6
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
.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by