Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Can somebody please help me with this Fourier series File?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Can somebody please help me on how to write this code for this file?
for the first part i have
fig = figure;
fig.WindowState = 'maximized';
function answer = Fourier(f,degree)
syms x;
answer = (1/(2.*pi)).*int(f,-pi,pi); % calculates a_0, the constant term
for n = 1:degree
coefficientOfSin = ((1/pi).*(int(f.*sin(n.*x),-pi,pi)));
coefficientOfCos = ((1/pi).*(int(f.*cos(n.*x),-pi,pi)));
answer = answer+(coefficientOfCos.*(cos(n.*x))+coefficientOfSin.*(sin(n.*x)));
end
end
the second part I have this, but i dont believe its right.
hold on;
syms x;
f=x.^2
fplot((x.^2)+1,[-1,1]);
for counter = 1:4
Tcounter = Fourier(f,counter);
fplot(Tcounter,[-1,1]);
end
axis equal;
axis off;
axis tight;
0 Kommentare
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!