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 Comment

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

Sign in to comment.

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Release

R2020a

Asked:

on 24 Jun 2021

Commented:

on 25 Jun 2021

Community Treasure Hunt

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

Start Hunting!