i can't plot this function in matlab
3 views (last 30 days)
Show older comments
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 Comments
Answers (2)
KSSV
on 6 Oct 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;
0 Comments
Star Strider
on 6 Oct 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
.
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!