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

please help Assi Develop a MATLAB m-file to generale a Fourier series of a squar

ID: 2079895 • Letter: P

Question


please help

Assi Develop a MATLAB m-file to generale a Fourier series of a square-wave in the time domain. Display the Fourier series for a square-wave based on different harmonic numbers Demonstrate the effects of band-limiting for a quare-wave. Coaument your results Write the code for an m-file (script) that will be used to generate the Fourier General Proced on should be based on a peak valor of square-wave. The representati pesik-to-peak) displayed a period of 1 Both the horizontal and vertical axee should be labeled aud the graph should be given a title The equations sue given Table 2-2 on page 50 of the class textbook. All plots should be generated with a Sumarme 1 for them-file. suffiaient sumber of points for smooth eurves Use the title submit yonr report in Blackboard ak a ward document file structured like this Pg 1 This page should be the cower page (Page 1) of the report. the following plots Pr 2,4 These pages will conta two eyales of the wavefonul for the following ease N-1: N-3; N-sa N-1. Nag. For each of the case above use Matlab to plot the amplitud kpectra lene-sided) cline Sunce for this signal the Phase speeta only to the negative sign of some of the in the anplitude specna and plot the 4oefficient thei Nome ponding ke just make sue that the plots EMs Pen 2, 4 or o figmes on a Page, er amange them as you "ather inserting all figues you davall indude a paragraph of comments tmed on tbe presctited. This varopraph cva be ou the satne page wih the laut Plot er as a serveate part

Explanation / Answer

Matlab Code


t = linspace(-4,4,1000000); % time interval is specified
fr = 0*t; % funcion value equal 0 is created
Nu=input('no of harmonics'); % user enters the number of harmonics
for p=-Nu:1:Nu
if(p==0) % zeroth term is skipped
continue;
end;
C_p = ((1)/(pi*1i*p))*(1-exp(-pi*1i*p)); % k-th Fourier coefficient of the exponential form is computed
f_p = C_p*exp(2*pi*1i*p*t); % series k-th term
fr = fr + f_p; % k-th term is added to f
end

plot(t, fr, 'LineWidth', 2);
xlabel('time');
ylabel('f(t) function');
title('Fourier series with user given harmonics');