Hello,(adsbygoogle = window.adsbygoogle || []).push({});

I've written a piece of code in MATLAB,to depict the function x(t)

I have the Fourier coefficients of this function as following:

a(k) = 1/(k.*pi)^2

where k is even andotherwise a(k) = 0.

also we know thatx(t+5) = x(t)

my code is :problem is, when MATLAB plots the function, it appears to have aCode (Text):

function [zaribX] = Ak(k)

if ~((mod(k,2) == 1) || k==0)

zaribX=1./(k.*pi).^2;

else zaribX=0;

end

return;

end

function [x] = FunctionX(Kmax,t)

x = 0;

for m = 0:Kmax

f = 2 .* abs(Ak(m)) .* cos( m .* ((2.*pi)./5) .* t + angle(Ak(m)));

x = x+f;

end

return;

end

period of 2.5, and not5. Could anyone help me see what's going wrong? Thanks a lot.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB plotting error?

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**