Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

See picture Shift SECTE Laboratory Notes c) Fourier series analysis periodic, tr

ID: 1846808 • Letter: S

Question

See picture

Shift SECTE Laboratory Notes c) Fourier series analysis periodic, triangular waveform Write a MATLAB program that calculates the Fourier coefficients of the plot the magnitude and the given in Equations (5) for k 19,20. The program should explain phase of ak. Record your observations of the plot and use the properties of the Fourier series to the observations. [5 marks] Hint: Consider using a row vector to store the Fourier coefficients allocate memory and initialise a zeros (1, 41) i for k 20 20 you must write code to compute coefficient ak i k 21 a (i) aki store a k in row vector a 20:20, stem (k, abs (a), plot magnitude of Fourier coefficients end

Explanation / Answer

Matlab code ->

function[ak] = cal_fs(x, w0, N)

ak = zeros(1,2*N+1); %intialize a row vector of 2N+1 zeros

T = 2*pi/w0; %calculate the period and store in T

syms t;

for k = -N:N

N=20;

ak(1,1+k+N) = 1/T * int(x * exp(-1i*k*w0*t), t, 0, T); % ak is fourier coefficient

end

k=-20:20;

stem(k,abs(ak),'filled');

xlabel('k');

ylabel('ak');

title('Magnitude of f(ak)');


syms x;

syms t;

x = 2*t;

w0 = 62;

N = 20;

cal_fs(x,w0,N)



% Fourier Series

a0=0;

Fy=zeros(1,41);

N=20;

for n=1:2:N

Fy=Fy+(4/n*pi)*sin(2*pi*n*t/(2*pi));

end

hold on,

plot(t,Fy,'r')

legend(' Square ','Fourier Approx');