- #1
farhadd
- 3
- 0
Hello,
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 and otherwise a(k) = 0.
also we know that x(t+5) = x(t)
my code is :
problem is, when MATLAB plots the function, it appears to have a period of 2.5 , and not 5. Could anyone help me see what's going wrong? Thanks a lot.
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 and otherwise a(k) = 0.
also we know that x(t+5) = x(t)
my code is :
Code:
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
problem is, when MATLAB plots the function, it appears to have a period of 2.5 , and not 5. Could anyone help me see what's going wrong? Thanks a lot.