Plotting the Fourier Series

Hi,
I am trying to plot the x(t) and t should be between -3 to 3. I calculate the a_k and I used the code given below. However, I could not get the plot what I expect. Capital T should be equal to 2. What is wrong in these lines? Thank you very much.
f=0;
t=linspace(-3,3);
for k=-100:1:100
a_k= (((pi^2)*(k^2)*(1^2)-2*(pi^2)*(k^2)-2*(2^2).*sin((k*pi*1/2))+2*pi*k*2*1.*cos((k*pi*1/2)))/2*(pi^3)*(k^3));
f=f+a_k*(exp(j*2*pi*k*t/2)); % for T=2
end
figure;
plot(t,f);

1 commentaire

Sharmin Kibria
Sharmin Kibria le 25 Juin 2021
Hi,
Can you write down the mathematical expression you are using for calculating the values of a_k? It will easier for me check if it getting calculated correctly.
Thanks
Sharmin

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Produits

Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by