Task 1 (3 points) Background: A function, J(x), is periodic over the interval of
ID: 3282863 • Letter: T
Question
Task 1 (3 points) Background: A function, J(x), is periodic over the interval of 0 S$ 128. (In other words, f(0) J(128). More generally,J(x)-??+128) for any x.) The values offx) are known at discrete points ofx = 0, 1, 2, 3, , 127, and 128. (Note that f(128) -f(0).)The data file, hw7taskldata.mat, stores two arrays, x and f, that contain the discrete values of x and the corresponding values off(x) at those discrete points. More precisely, After downloading the data file and placing it in your working directory, the data can be read by Matlab using the "load" command. The following code reads the data and produces a quick plot to confirm that the x and f arrays have been read correctly: clear load ('hw7taskldata.mat') plot (x, f, 'k-') axis([0 128 -6 6]) ;xlabel ('x') ;ylabel ('f (x) ') (a) Express/(x) in Fourier series, f(x) = a0 + ? a, cos( 2 n ? x) + b, sin ( 2 n ? x) where L = 128. Your first task is to use the data given in Background to evaluate the Fourier coefficients ao, al, bi, a2, b2, , etc. List the values of all coefficients for n 20 (including n-0). You do not need to evaluate the coefficients with n > 20.Explanation / Answer
Hi, Here is the complete MATLAB code. I have put comments for the new code being added.
clear
x = [0:1:128];
f = [5.3 5.348555523964721 4.87575709728591 4.493531656941824 4.564538677572919 4.867554212554258 4.886217565340741 4.387923222987208 3.672008164454192 3.234924992721203 3.223781135781007 3.268299451334995 2.871746582154257 1.945338461763224 0.9203007240097916 0.3208465923408997 0.248528137423856 0.3134188744328628 0.06760716068252542 -0.5317714732149155 -1.118020876546854 -1.351349157908483 -1.301791687185019 -1.350866406215986 -1.72144917423745 -2.168223248287015 -2.20185270267216 -1.637063221739037 -0.8735469649430661 -0.5660650026999798 -0.9782198191271849 -1.675481559813334 -1.9 -1.28483035930156 -0.2091496714275773 0.5572334731997024 0.5683726790708283 0.07725187803598277 -0.2709495982390619 -0.08486822185480911 0.4433352263473369 0.8190382328410595 0.7933602721997776 0.5874216901393201 0.5828393129876577 0.8516075695474321 1.057719081421364 0.8400131809673694 0.2485281374238567 -0.2601606911092016 -0.2861541421371659 0.08006774940952607 0.3262294210085913 0.03365570864357942 -0.6959724829306509 -1.352952899385628 -1.554243695051315 -1.434664014517765 -1.479116914242675 -1.976375301643753 -2.684480893250175 -3.079131555411074 -2.932743152331716 -2.603332340715091 -2.699999999999998 -3.446459136989382 -4.400708020098421 -4.843721354590307 -4.468245785518665 -3.682590519668875 -3.223984072891561 -3.465456268644514 -4.096272233166121 -4.46518057100459 -4.210679421556259 -3.544749411888669 -2.949468560012865 -2.65652616146632 -2.468111663164587 -2.070506011828034 -1.448528137423859 -0.9176441279134815 -0.7371070995548193 -0.7525678966080938 -0.5013134204422529 0.2944305592151065 1.370249735284047 2.112905211660661 2.145713242949383 1.713973066783028 1.458059447899197 1.785468088100697 2.474310347736518 2.911781769874572 2.720481619966783 2.127269845805756 1.7 1.736618645293979 1.951411472267173 1.788483293974887 1.032390703722635 0.07115298832567823 -0.472843656533898 -0.3693819596491897 -0.01907115763540601 -0.05699942739638159 -0.7249022241007353 -1.644340288832693 -2.202173609976766 -2.135946939370451 -1.727219020293655 -1.444238434447987 -1.448528137423855 -1.489498728377935 -1.261656797017635 -0.7912554491126145 -0.4039513988671993 -0.3101056691972476 -0.2909258028445969 0.1226973211022328 1.129979626339365 2.357130968860466 3.141350406691855 3.161338994529143 2.780773785304441 2.728941857762588 3.407792229519208 4.505428727690425 5.299999999999995];
plot(x,f,'k-')
axis([0 128 -6 6]);xlabel('x');ylabel('f(x)')
%generate fourier coefficients
coeff = fft(f,21)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.