Sunteți pe pagina 1din 19

UNIVERSIDAD SAN FRANCISCO DE QUITO

MAESTER NANOELECTRONICS

SIGNAL ANALYSIS

HOMEWORK OF

FOURIER ANALYSIS

NAMES:

DIEGO FERNANDO CRIOLLO

JUAN CARLOS BECERRA

DATE: 03/10/2017
Exercise 1 In this problem, we consider the following even periodic function of period 2:

1. Calculate the Fourier coefficients of f


2. Based on the coeffcients calculated above, write a Matlab program that calculates the
Fourier Series of f for an arbitrary number of harmonics n on one period.

clc, clear all, close all; %Close and Clear all

te=0:0.001:(2*pi); % square period


for i=1:length(te)
if te(i)>=0 & te(i)<pi
x(1,i)=1; %Drawing the function
end
if te(i)>=pi & te(i)<=2*pi
x(1,i)=0;
end
end
plot(te,x);

syms x n; %Simbols
T=2*pi;
bn=0; % Declaration of variables
a0=0;
f=0;
fun1=1+0*x;
a0=a0+(2/T*int(fun1,x,0,pi)); % Calculate a0 in
semiperiod (0 to pi)
bn=bn+(2/T*int(fun1*sin(x*2*pi*n/T),x,0,pi)); % Calculate bn in
semiperiod (0 to pi)
an=0; % an=0
fun2=0*x; % Funtion = 0
bn=bn+(2/T*int(fun2*sin(x*2*pi*n/T),x,pi,2*pi)); % Calculate bn in
semi period (pi to 2*pi)
a0=a0+(2/T*int(fun2,x,pi,2*pi));
an=0;
leg(1)={'original function'};
for j=1:3 % To select number
of times to plot
f=0;
f1=0;
N=input('enter the value of the constant N: ') % Input N

% Contruction of Fourier
for i=1:N
n=i;
b=subs(bn); % Subtract bn
c=subs(an); % Subtract an
f=f+c*cos(2*n*pi*x/T)+b*sin(2*n*pi*x/T); % Total funtion
ind(i)=b;
numero(i)=n;
end
a=subs(a0);
f1=a/2+f;
num=1;
for jj=0:0.01:2*pi
d(num)=subs(f1,jj);
e(num)=jj;
num=num+1;
end
value_max_fourier=vpa(max(d))
position_max=find(d==max(d)); % Catch max
position
position_max=e(position_max)
value_min_fourier=vpa(min(d))
value_min_fourier=find(d==min(d)); % Catch min value
value_min_fourier=e(value_min_fourier)
hold on;
ezplot(f1,[0 2*pi]); % Plot
dato=['N=',num2str(N)];
leg(j+1)={dato};
end
grid on;
title('fourier series analysis')
legend(leg,'FontName','Times New Roman','Fontsize',15)
figure(1)
figure(2)
stem(numero,ind)

3. For various values of n, plot the Fourier Series around the discontinuity and compare it
with f. What can you conclude?
The signal given in exercise 1 represented in Matlab is as follows

The signal represented is blue and meets the proposed limits, where it is taken as an odd
function.
On two separate plots (or subplots), display the position and the amplitude as a function of the
number of terms in the series.
Con N=1, 3, 5
In the command window you can vary the value n of the Fourier series you can enter 3 different
values of n before you can see the graph.
Figure 1
The figure 1.1 indicates the position of the amplitude of agreement to the number of terms of
the Fourier series correposing to figure 1.

Figure 1.1

Following values
N= 10, 15, 20
Figure 2

Figure 2.1

Following values
N= 50, 75, 100
Figure 3

Figure 3.1

Following values
N= 200, 500, 1000

Figure 4

Figure 4.1

Record both the position and value of the maximum of the Fourier Series. This maximum
should be in the vicinity of the discontinuity.

The position and the maximum and minimum values of the series are printed in the matlab
command window, as long as each value of N is executed, the values are to be calculated
Conclusions

.- If we represent successive approximations for n increasing, we appreciate that the


approximation is convergent for areas outside the vicinity of the points of discontinuity.
.- While the value of n grows the series is approaching the original function.

.- In conclusion, we can say that the Fourier series are of great importance for engineering since
they allow us, without much complexity, to model and respond to everyday events that are great
importance to know them for the advancement of technology and better human well-being.

Square signal If we assume that a pure sinewave of period 2_ and amplitude A, sufficiently
large, is injected into an ampli_er of very large gain, the output signal, after saturation, can be
approximated by a square signal. The output signal, can therefore be expressed on one period
by:

Based on the Fourier series for this signal, calculate, with pen and paper, the total harmonic
distortion.
3 .-Triangle signal In this second part of the exercise, we are studying the THD associated with
a triangular signal. We re considering the following periodic function of period 2:
1. With pen and paper, calculate the coeffients of the Fourier series of g.
2.- Based on the coe_cients calculated above, write a Matlab program thatcalculates the Fourier
Series of f for an arbitrary number of harmonics n on one period.

PROGRAM:

clc;clear all;close all; %Close and Clear all


te=0:0.001:2 %Selection square period
y=zeros(length(te));

for i=1:length(te) %
if te(i)>=0 & te(i)<1 %
y(i)=te(i); % Drawing the original
end % funtion
if te(i)>=1 & te(i)<=2 %
y(i)=2-te(i); %
end
end
plot(te,y(:,1),'-b'); % Graphic
hold on

syms x n; % Simbols Function


T=2; % period
bn=0;
an=0;
a0=0;
f=0;
fun1=x; % Function semiperiod 1
a0=a0+(2/T*int(fun1,x,0,1)); % Calculation of a0 of semiperiod 1
bn=bn+(2/T*int(fun1*sin(x*2*pi*n/T),x,0,1)); % Calculation of b0 of semiperiod 1
an=an+(2/T*int(fun1*cos(x*2*pi*n/T),x,0,1)); % Calculation of an of semiperiod 1
fun2=-x+2; % Function semiperiod 2
bn=bn+(2/T*int(fun2*sin(x*2*pi*n/T),x,1,2)); % Calculation of bn of semiperiod 2
a0=a0+(2/T*int(fun2,x,1,2)); % Calculation of a0 of semiperiod 2
an=an+(2/T*int(fun2*cos(x*2*pi*n/T),x,1,2)); % Calculation of an of semiperiod 2
bn;
leg(1)={'ORIGINAL FUNCTION'};
for j=1:3 % To select number of times to plot
f=0;
f1=0;
N=input('INPUT N: ')
% Contruction of Fourier
for i=1:N
n=i;
b=subs(bn); % Subtract bn
c=subs(an); % Subtract an
f=f+c*cos(2*n*pi*x/T)+b*sin(2*n*pi*x/T);% Calculation function
ind(i)=-c;
numero(i)=n;
end
a=subs(a0); % Substract a0
f1=a/2+f; % Funtion
hold on;
ezplot(f1,[0 2]); % W0
dato=['N=',num2str(N)];
leg(j+1)={dato};
end
grid on;
title('FOURIER ANALYZE')
legend(leg,'FontName','Times New Roman','Fontsize',15)
figure(1) % Plot Fourier
figure(2) % Plot W
stem(numero,ind)

3. Increase the value of n and check that the Fourier series converge towards g.

ORIGINAL FUNCTION

ANALYZE WITH N=1, N=10 AND N=50


ZOOM OF SIGNAL, ANALYZE WITH N=1, N=10 AND N=50

ANALYZE WITH N=50, N=200 AND N=500


ZOOM OF SIGNAL, ANALYZE WITH N=50, N=200 AND N=500

CONCLUTION:

The higher the value of N, the more it resembles the original signal.
4. Based on the de_nition of THD, calculate the THD of g. How does it compare with the THD of
the square signal in section 1? Could we have expected such a result from the Fourier
coefficients expression?

We can observe that THD of the triangular signal is smaller than the THD of the square signal.
This result was expected because the triangular signal is more similar to sin signal.

S-ar putea să vă placă și