How to plot both real and imaginary part of complex exponential?
    9 次查看(过去 30 天)
  
       显示 更早的评论
    
Hi, I'm new to matlab since I try to plot this signal as complex exponential form with 5 terms but I got stuck 

clc;
clear all;
close all;
t0 = 0;
T = 10;
k = 1:6
w = 2*pi/T
syms t
x =  t^2 +(j*2*pi*t)
x1 = real(x)
y = imag(x)
k1 = -2: 2; %%% 5 terms
a = (1/T)*int(x*exp(-j*k1*w*t),t,t0,t0+T);
%%% i dont know how to plot it please help
0 个评论
回答(1 个)
  Star Strider
      
      
 2020-10-27
        For best results, replace ‘j’ with ‘1j’, then convert the result to double to use plot (since fplot is likely to be more difficult with discrete values of ‘k1’): 
a = (1/T)*int(x*exp(-1j*k1*w*t),t,t0,t0+T);
num_a = double(a);                              % Convert To ‘double’ To Plot
figure
plot(k1,real(num_a))
hold on
plot(k1,imag(num_a))
plot(k1,abs(num_a),'--k')
hold off
grid
legend('\Re(a)','\Im(a)', '|a|')
That should do what you want.  
Otherwise, I would have suggested: 
syms k2
a(k2) = (1/T)*int(x*exp(-1j*k2*w*t),t,t0,t0+T);
figure
fplot(real(a), [-2 2])
hold on
fplot(imag(a), [-2 2])
fplot(abs(a), [-2 2], '--k')
hold off
grid
legend('\Re(a)','\Im(a)', '|a|')
.
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

