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;
0 个评论
回答(2 个)
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;
0 个评论
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
.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!