Use the provided MATLAB program (fourier_synthesis.m) to generate 4 plots the Fourier series approximations of the signals from problem 5 (3.22 in the text parts (a,b,e,f)). For each of the four plots, show the functions obtained by using 3, 5, 7, and 15 coefficients, ak, from the Fourier series to approximate the provided function x(t). Note You should add coefficients starting at a0 and then add coefficients that are complex conjugates of one another (since these are real-valued functions), e.g., the plot with 3 coefficients will include a0, ak0, a−k0. For some plots the average value, i.e., a0, may be equal to 0 (3.22(a,e)).

Respuesta :

Explanation:

With the Fourier series approximation we can represent any function with just sine and cosine waves having different frequencies. As we increase the number of harmonics the approximation gets closer and closer to the real function.

Matlab Code:

% time vector

t=0:0.001:6;  

f=0;

% run a for loop for the summation of harmonics, it will skip for n = even because the Fourier coefficients of a square wave are zero for n = even  

for n=1:2:15;  

% the Fourier representation of square wave you can change this function as required

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

% plot a graph when number of harmonics are 3

if n==3  

f1=f;

% 2 rows and 2 columns total 4 plots

subplot(2,2,1);

% increased line width with red color  

plot(t,f1,'r','Linewidth',2)

grid on

title('n = 3')

xlabel('Time')

ylabel('Amplitude')

axis tight

end

% plot a graph when number of harmonics are 5

if n==5  

f1=f;

subplot(2,2,2);

% increased line width with blue color  

plot(t,f1,'b','Linewidth',2)

grid on

title('n = 5 ')

xlabel('Time')

ylabel('Amplitude')

axis tight

end

% plot a graph when number of harmonics are 7

if n==7  

f1=f;

subplot(2,2,3);

% increased line width with magenta color  

plot(t,f1,'m','Linewidth',2)

grid on

title('n = 7')

xlabel('Time')

ylabel('Amplitude')

axis tight

end

% plot a graph when number of harmonics are 15

if n==15  

f1=f;

subplot(2,2,4);

% increased line width with black color  

plot(t,f1,'k','Linewidth',2)

grid on

title('n = 15')

xlabel('Time')

ylabel('Amplitude')

axis tight

end

end

Output:

Please refer to the attached plot, as you can see in the attached graph as we are increasing the number of harmonics, the plot is getting more and more closer to a square wave. This is the beauty of Fourier series.

Ver imagen nafeesahmed