x(t)

advertisement
Signals&Systems Laboratory 2013/2014
1
Experiment 3.
Fourier Series. Signal expansion and synthesis.
Introduction
a) Fourier series.
Consider a periodic signal x(t) with period T. If some conditions (see Dirichlet
conditions from lecture book) are satisfied, the function (signal) x(t) can be expressed as
series:

xt   a0   an cosn0t  bn sin n0t 
(1)
n 1
2
 2f 0 .
T
Coefficients of the trigonometric Fourier series may be calculated from the following
relations:
where 0 
1T
1 t T
a0   f t  dt   f t  dt
T0
T t
0
(2)
0
2T
2 t T
am   f t  cos m0tdt   f t  cos m0tdt
T0
T t
m  1, 2,...
(3)
2T
2 t T
bm   f t sin m0tdt   f t sin m0tdt
T0
T t
m  1, 2,...
(4)
0
0
0
0
where t0 is any real number.
Formula (1) can be also expressed in more convenient equivalent form:

f t   A0   An cosn0t   n 
(5)
n1
Cosine terms in (1) and (5) are called harmonic (n-th harmonic has amplitude An , phase
 n and angular frequency n 0 , constant term A0  a0 (2) is the 0-th harmonic. First
harmonic:
y1 t   a1 cos 0t  b1 sin 0t  A1 cos 0t  1 
(6)
is called usually basic harmonic with angular (basic) frequency 0  2f 0 . The plot of
amplitude An i terms of n is called amplitude spectrum and plot of phase as a function of
n is called phase spectrum. Amplitudes and phases may be calculated from the relations:
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
Signals&Systems Laboratory 2013/2014
2
An  an2  bn2
(7)
 bn
(8)
an
The periodic signals are often presented in more compact form called exponential
Fourier series:
 n  arctan
xt  

 c~ e
n 
jn0t
(9)
n
where
1 t T
~
cn   xt  e  jn t dt
n  1, 2, ... .
T t
Relations between different Fourier series forms are specified as follows:
0
0
(10)
0
1 t T
~
c0   f t  dt  a0  A0 .
T t
0
(11)
0
b
1 2
1
c~n 
an  bn2  An ,  n  arg c~n  a tan n
2
2
an
n  1,2,3....
Similarly, the plot of c~n versus n is called the amplitude spectrum and the plot of
 n  arg c~n versus n is called phase spectrum. Note, that following relationships are
valid:
c~n  c~n ,  n   n n  1,2,3....
b) How to compute coefficients.
The amplitude and phase spectra, based on formulas (5) or (10) can be computed
by use of Matlab integration formulas like:
int
Symbolic integration
Syntax
int(expr,var,a,b)- computes the definite integral of expr with respect to
var from a to b.
More often, Fourier series computations are performed numerically using the
Discrete Fourier Transform (DFT), which in turn is implemented numerically using an
efficient algorithm known as the Fast Fourier Transform (FFT). Assuming, that
sampling frequency used for discretization of the periodic function interval is equal to fs
(samples per second) and applied DFT transform has N-elements, basic harmonic of the
Fourier series may be calculated from he formula:
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
Signals&Systems Laboratory 2013/2014
3
fo 
fs
N
.
(12)
Frequence of the next stripes of Fourier series spectrum are of the form:
.
fi 
if s
N
(13)
Constant term and amplitudes of the harmonics (up to i=N/2) of the Fourier series
having form(5) follows the relations:
Ai  2
Xi
N
, i  1,2,...,
N
2
2
j
N
X n   xm wmn , n  0,1,2,..., , w  e N
2
m 0
N 1
(14)
Phases of the harmonic are computed from the arguments (command angle)of Xn.
As an illustration, the following code (core of the m-file) shows how to use fft approach
to obtain Fourier expansion coefficients. You can study this code and further enhance it
to complete your work.
function [SpecAmp,SpecPh,Y1]=Spectrum_by_FFT_2013(fun,N,T)
%N==> dlugosc transformaty DFT (Length of DFT)
%T==> czas pomiaru (wielokrotnosc okresu?) (oservation time,
suggested:multiplicity of the period T)
ts=(T/N);
fs=1/ts;%
t1=0:ts:T;
ta=0:0.01*ts:T;
n1=0:1:N/2;
y1=feval(fun,t1); %function 'fun' after disretization for DFT
ya=feval(fun,ta); %function 'fun' after discretization enabling to
print analog curve
Y1=fft(y1,N); %
Y1(2+N/2:N)=[]; %
SpecAmp=abs(Y1)*2/N; %
SpecAmp(1,1)=SpecAmp(1,1)/2; %
SpecPh=(abs(Y1)>0.01).*angle(Y1)*180/pi;
y=synth(T,N,SpecAmp,SpecPh,ta);
subplot(5,1,1);plot(ta,ya);grid on;
subplot(5,1,2);stem(n1,SpecAmp);grid on;
subplot(5,1,3);stem(n1,SpecPh);grid on;
subplot(5,1,4:5);plot(ta,y);grid on;
function y=synth(T,N,Amp,faza,x); %
y=zeros(1,length(x));
for i=1:N/2
y=y+Amp(i+1).*(cos(i*2*pi*(T^-1).*x+faza(i+1)*pi/180));
end
y=y+Amp(1);
return
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
Signals&Systems Laboratory 2013/2014
4
Useful Matlab functions: fft(x,N), length(), abs, angle, stem figure, xlabel, ylabel, title.
Numerical calculations may be performed also by Simulink models (available only in
Matlab 5.3 installation). Exemplary scheme is shown in Fig.1
Fig.1. FFT based algorithm for finding harmonic’s coefficients – Simulink
implemetation.
Fig.3.Block parameters..
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
Signals&Systems Laboratory 2013/2014
5
2) Laboratory work
For given set of periodic signals calculate Fourier series
coefficients (for all three forms) using
i) FFT-based method - Matlab script (open Matlab 5.3) delivered by your teacher
(from website).
ii) Numerical integration (Symbolic Toolbox from Matlab 2013b)
(1) Find Fourier expansions (approximations) in the form (1) , (5) and (9).
Complete Table with coefficients, plot spectra. Discuss the coefficients
of various Fourier series in relation to the symmetry of the signal.
(2) Observe the Gibbs phenomena (changing number of synthesized
harmonics). Briefly explain!
(3) Observe, what happens, if the sampling period Ts is not an integer
multiplicity of the signal period T.
TABLE
for SIGNAL
………..
METHODS
Analytical solution
Coeff.
a0
A0
c0
a1
b1
A1
c1
1
:
an
bn
An
cn
n
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
Numerical integration
(Symbolic Toolbox)
FFT concept
Signals&Systems Laboratory 2013/2014
6
fT(t)
A
T
a
0
B
Fig.4a
gT(t)
A
T
0
a
b
c
B
Fig.4b
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
d
e
Signals&Systems Laboratory 2013/2014
7
f 1 (t)
2
1
0
T/4
T
T/2
-2
f 2 (t)
2
1
0
T/4
T/2
T
t
f 3 (t)
2
1
0
T/4
T
T/2
-2
Fig.5
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
t
Signals&Systems Laboratory 2013/2014
8
Exemplary m-file enabling us to calculate (and plot)
Canonical Fourier Series Coefficients
% Plotting the Fourier Series Coefficients
% Współczynniki kanonicznej postaci Szeregu Fouriera
syms t k n
%x=exp(-t);
x=triangle1(t); % funkcja zawierająca opis sygnału (function
containing signal description)
to=0;
T=4;
w=2*pi/T;
ao=(1/T)*int(x,t,to,to+T);
a=(2/T)*int(x*cos(n*w*t),t,to,to+T);
n1=1:6;
a=subs(a,n,n1);
an=[eval(ao) a];
n2=[0 n1];
b=(2/T)*int(x*sin(n*w*t),t,to,to+T);
n1=0:6;
bn=subs(b,n,n1);
subplot(2,1,1);
A=sqrt(an.^2+bn.^2);
stem(n2,A);grid on
title('Canonical Fourier Series Coefficients: Amplitude An')
legend('An,n=0:6')
subplot(2,1,2);
thita2=atan2(-bn.*(abs(bn)>0.0001),an)*180/(1*pi);
stem(n1,thita2);grid on
title('Canonical Fourier Series Coefficients: Phase theta_n')
legend('\angle thita,k=0:6')
Canonical Fourier Series Coefficients: Amplitude An
1
An,n=0:6
0.5
0
0
1
2
3
4
5
6
Canonical Fourier Series Coefficients: Phase theta n
100
 thita,k=0:6
50
0
-50
-100
0
1
Departament of Nonlinear Circuits and Systems
copyrights mhonwia 2013-12-15
2
3
4
5
6
Download