Graphing complex fourier series

조회 수: 57 (최근 30일)
Santiago Restrepo García
Santiago Restrepo García 2020년 5월 15일
답변: Priyanshu Mishra 2020년 5월 18일
Hi MatLab Community, I hope you are well
I've been trying to plot the graph of a complex fourier series and I haven´t be able to do it
The original signal x(t) is an square with To = 1 and Wo = 2*pi,
x(t) = 1, -1/4<= t <= 1/4, -1 something else
I calculated the C_n coefficient and it is
C_n = (1/(pi*n))*sin((pi*n)/2)+(1/(1i*2*pi*n))*(exp(-1i*3*pi*n/2)-exp(-1i*pi*n/2))
But when I tried to plot it a warning "Warning: Imaginary parts of complex X and/or Y arguments ignored. " appears
If I expand x(t) by the trigonometric method I could plot the Fourier series succesfully
This is my code.
T = 1;
W = (2*pi)/T;
t = [-2*pi:0.0001:2*pi];
x_t = 0;
for n = -100:100
C_n = (1/(pi*n))*sin((pi*n)/2)+(1/(1i*2*pi*n))*(exp(-1i*3*pi*n/2)-exp(-1i*pi*n/2));
x_t = x_t + C_n*exp(1i*n*W*t);
end
plot(t,x_t)
I hope you could help me, thank you

답변 (1개)

Priyanshu Mishra
Priyanshu Mishra 2020년 5월 18일
Hi Santiago,
You are getting this warning because you are attempting to plot a complex input with plot function. If you want to plot imaginary part, I would suggest you pass the imaginary part to the plot function. For reference you may use this code :
T = 1;
W = (2*pi)/T;
t = [-2*pi:0.0001:2*pi];
x_t = 0;
for n = -100:100
C_n = (1/(pi*n))*sin((pi*n)/2)+(1/(1i*2*pi*n))*(exp(-1i*3*pi*n/2)-exp(-1i*pi*n/2));
x_t = x_t + C_n*exp(1i*n*W*t);
end
plot(t,imag(x_t))

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by