How to Plot a Fourier Series?
Hi,
I was given a half range expansion function f(x) = 0, 0<x<2 and f(x) = 1, <2<x<4.
I was asked to solve for the Fourier cosine series and Fourier sine series and then plot each.
I solved by hand:
Fourier Cosine Series:
a0 = 1/2
an = -2/(n*pi)*sin((n*pi)/2)
f(x) = 1/2 + sum(an*cos((n*pi*x)/4)) from n =1 to infinity
Fourier Sine Series:
bn = [2/(n*pi)]*[(-1)^(n+1) + cos((n*pi)/2)]
f(x) = sum(bn*sin((n*pi*x)/4))
I’m fairly new to Matlab and very unexperienced, where I’m having dificulty is plotting these functions against x, say x = [-24 24] and n=1:1:50 or until square waves appear. I gained some experience plotting their partial sums using fplot, but that approach does not appear to work here. It isn’t feasible to plot the 50th partial sum. I’ve seen more arrayfun usage online, but I do not understand it whatsoever.
Any help and explanation would be greatly appreciated. Thanks in advance.Hi,
I was given a half range expansion function f(x) = 0, 0<x<2 and f(x) = 1, <2<x<4.
I was asked to solve for the Fourier cosine series and Fourier sine series and then plot each.
I solved by hand:
Fourier Cosine Series:
a0 = 1/2
an = -2/(n*pi)*sin((n*pi)/2)
f(x) = 1/2 + sum(an*cos((n*pi*x)/4)) from n =1 to infinity
Fourier Sine Series:
bn = [2/(n*pi)]*[(-1)^(n+1) + cos((n*pi)/2)]
f(x) = sum(bn*sin((n*pi*x)/4))
I’m fairly new to Matlab and very unexperienced, where I’m having dificulty is plotting these functions against x, say x = [-24 24] and n=1:1:50 or until square waves appear. I gained some experience plotting their partial sums using fplot, but that approach does not appear to work here. It isn’t feasible to plot the 50th partial sum. I’ve seen more arrayfun usage online, but I do not understand it whatsoever.
Any help and explanation would be greatly appreciated. Thanks in advance. Hi,
I was given a half range expansion function f(x) = 0, 0<x<2 and f(x) = 1, <2<x<4.
I was asked to solve for the Fourier cosine series and Fourier sine series and then plot each.
I solved by hand:
Fourier Cosine Series:
a0 = 1/2
an = -2/(n*pi)*sin((n*pi)/2)
f(x) = 1/2 + sum(an*cos((n*pi*x)/4)) from n =1 to infinity
Fourier Sine Series:
bn = [2/(n*pi)]*[(-1)^(n+1) + cos((n*pi)/2)]
f(x) = sum(bn*sin((n*pi*x)/4))
I’m fairly new to Matlab and very unexperienced, where I’m having dificulty is plotting these functions against x, say x = [-24 24] and n=1:1:50 or until square waves appear. I gained some experience plotting their partial sums using fplot, but that approach does not appear to work here. It isn’t feasible to plot the 50th partial sum. I’ve seen more arrayfun usage online, but I do not understand it whatsoever.
Any help and explanation would be greatly appreciated. Thanks in advance. arrays, function, time series MATLAB Answers — New Questions