Fourier series doesnt overlap function
Info
This question is closed. Reopen it to edit or answer.
Show older comments
b = zeros(1,7);
x = linspace(-2,2,200);
f = ((8+x.^3)).^(1/2);
b0 = trapz(x,f);
for n = 1:7
y = f.*sin(n*pi*x/2);
b(n) = trapz(x,y);
end
fh = zeros(1,200);
for n = 1:7
fh = fh + b(n)*sin(n*pi*x/2);
end
fh = b0/2 + fh;
plot(x,f,'r','LineWidth',3)
hold on
plot(x,fh,'b','LineWidth',1)
hold off
legend('f','fh','Location','best')
title('N/A')
Can anyone see why the fourier series of f doesnt line up with the function f?
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!