Question: Writing a (Matlab) function to find fourier coefficients. t is the time interval,0:0.001:6*pi, x is the waveform function (cos(t) for example), N is the #
Writing a (Matlab) function to find fourier coefficients. t is the time interval,0:0.001:6*pi, x is the waveform function (cos(t) for example), N is the # of terms desired in the fourier series, and T is the waveform's fundamental period. Need help fixing THIS code to make it work for the given parameters and outputs, using the two "for loops". Thanks function [average, a_k, b_k] = fourier(t, x, T, Y) dt = 0.01; for k = l;y for q = l:T a(k) = a(k)+(2/T)*(x(q))*cos(k*pi*t(q))*dt b(k) = b(k)+(2/T)*(x(q))*sin(k*pi*t(q))*dt; average = mean(x); end end average = double(mean(x)); a_k = double(a(k)); b_k-double (b(k)); end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
