Question: clear all; clc; close all NumberOfHarmonics = 10; N = NumberOfHarmonics-1; % number of signal components t = 0:.1:4*pi; % making small increments on the

clear all; clc; close all NumberOfHarmonics = 10; N = NumberOfHarmonics-1; % number of signal components t = 0:.1:4*pi; % making small increments on the time axis % plotting the given signal tsq = .5*square(t); tsq = circshift(tsq',-16)+.5; figure; hold on; box on plot(t, tsq, 'linewidth', 2); lgnd{1} = 'Given signal'; set(gca,'xtick', [pi/2 pi 3*pi/2 2*pi 5*pi/2 3*pi 7*pi/2 4*pi]) set(gca,'xticklabel', {'\pi/2','\pi', '3\pi/2', '2\pi', '5\pi/2' ... '3\pi', '7\pi/2', '4\pi'}) % Code for Fourier Series a0 = 1/2; % comes from the FS math plotID = 1; ft = a0; for n = 1: 2 : 2*N+1 an = sin(n*pi/2)/(n*pi/2); % comes from the FS math ft = ft + an*cos(n*t); plot(t, an*cos(n*t), 'color',[rand, rand, rand]); plotID = plotID + 1; lgnd{plotID} = ['cos' num2str(plotID-1)]; end plot(t, ft, '-r', 'linewidth', 2) plotID = plotID + 1; lgnd{plotID} = 'Fourier Representation'; legend(lgnd, 'location', 'northeastoutside') xlabel('t') ylabel('f(t)')This scripts generates the Fourier coefficients corresponding to the following periodic signal. f(t) 1 -51/2 -31/2 -1/2 1/2 31/2 51/2 Use the above Matlab script to (a) Derive the trigonometric Fourier series coefficients of the above signal. (b) Approximate the function f(t) above using one cosine function only (plot f(t) and the one harmonic approximation you found on the same plot (you will find the above Matlab function useful) (c) Approximate the function f(t) above using the first five cosine functions only (plot f(t) and the five harmonic approximation you found on the same plot. Question 2 Modify the Matlab code in Q1 above to obtain the Fourier series approximation of the following signal 1 Example a fet) -4TT -27 299 (a) Derive the trigonometric Fourier series coefficients of the above signal. (a) Approximate the function f(t) above using one sine function only (plot f(t) and the one harmonic approximation you found, on the same plot. (b) Approximate the function f(t) above using the first five sine functions only (plot f(t) and the five harmonic approximation you found, on the same plot. This scripts generates the Fourier coefficients corresponding to the following periodic signal. f(t) 1 -51/2 -31/2 -1/2 1/2 31/2 51/2 Use the above Matlab script to (a) Derive the trigonometric Fourier series coefficients of the above signal. (b) Approximate the function f(t) above using one cosine function only (plot f(t) and the one harmonic approximation you found on the same plot (you will find the above Matlab function useful) (c) Approximate the function f(t) above using the first five cosine functions only (plot f(t) and the five harmonic approximation you found on the same plot. Question 2 Modify the Matlab code in Q1 above to obtain the Fourier series approximation of the following signal 1 Example a fet) -4TT -27 299 (a) Derive the trigonometric Fourier series coefficients of the above signal. (a) Approximate the function f(t) above using one sine function only (plot f(t) and the one harmonic approximation you found, on the same plot. (b) Approximate the function f(t) above using the first five sine functions only (plot f(t) and the five harmonic approximation you found, on the same plot
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
