Graphing complex fourier series

54 visualizaciones (últimos 30 días)
Santiago Restrepo García
Santiago Restrepo García el 15 de Mayo de 2020
Respondida: Priyanshu Mishra el 18 de Mayo de 2020
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

Respuestas (1)

Priyanshu Mishra
Priyanshu Mishra el 18 de Mayo de 2020
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))

Community Treasure Hunt

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

Start Hunting!

Translated by