How to plot both real and imaginary part of complex exponential?
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Star Strider
el 27 de Oct. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!