How to plot both real and imaginary part of complex exponential?
조회 수: 22 (최근 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!