Nothing Special   »   [go: up one dir, main page]

Module 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Module -4 (Fourier Series Analysis) –Part 1

Continuous time signals:


Compute and plot of the Fourier coefficients for a periodic signal:
For a signal shown in fig below,
e-t/2
x(t)
1

-3π -2π -π 0 π 2π 3π t (secs)

Method 1: Manually derive the expression for Fourier coefficients, (a o, an, bn, Cn, θn )
and then plot using the following MATLAB code
clc; clear; clf;
n= 1:10; an(1) = 0.504; an(n+1) = 0.504*2./(1+16*n.^2);
bn(1) = 0; bn(n+1) = 0.504*8*n./(1+16*n.^2);
cn(1) = an(1);
cn(n+1) = sqrt(an(n+1).^2+bn(n+1).^2);
thetan(1) = 0; thetan(n+1) = atan2(-bn(n+1),an(n+1));
n=[0,n];
subplot(2,2,1); stem(n,an,'k'); ylabel('an'); xlabel('n');
subplot(2,2,2); stem(n,bn,'k'); ylabel('bn'); xlabel('n');
subplot(2,2,3); stem(n,cn,'k'); ylabel('cn'); xlabel('n');
subplot(2,2,4); stem(n,thetan,'k'); ylabel('\theta[rad]'); xlabel('n');
O/P -----> All the coefficients will be plotted against n

Manually derive the expression for Exponential Fourier coefficients for a periodic signal
and then plot using the following MATLAB code
n= -10:10; dn = 0.504./(1+j*4*n);
subplot(2,1,1); stem(n,abs(dn),'k'); ylabel('|dn|'); xlabel('n');
subplot(2,1,2); stem(n,angle(dn),'k'); ylabel('\angle dn [rad]');xlabel('n');

Method 2: write code to compute Fourier series coefficients either by creating m-function
file or directly in m-script file: A sample of MATLAB code is here for your reference:
wo = 1; h = 0.001; To = 2*pi/wo; t = 0:h:(To-h);
y = 1 + 6*cos(wo*t) + 3*sin(2*wo*t).*cos(wo*t)+ 2*sin(3*wo*t)+5*cos(5*wo*t);
N = length(y); co = sum(y)/(N-1);
for n = 1:10
aa(n) = 2*sum(y.*cos(n*wo*t))/(N-1); bb(n) = 2*sum(y.*sin(n*wo*t))/(N-1);
end
cn = sqrt(aa.^2+bb.^2); thetan = atan(-bb./aa);
Exercises:
1) For the above example, plot Fourier series expanded signal x(t) vs. continuous time t
and also plot each (at least 5) Fourier series terms w. r. t. continuous time t, explicitly
in the same graph sheet, and observe the role of Amplitude and Phase Spectra in Wave
shaping. (Use inline functions if necessary)
2) For the above example, find and sketch the Fourier series coefficients of the signal
x(-t). Compare the results with the F.S of x(t).
3) For the above example, find and sketch the Fourier series coefficients for the time
compressed / expanded signal. And observe the change in the Fourier spectra.
Compare the results with the F.S of x(t).
4) For the above example, find and sketch the Fourier Spectra for the time delayed
x(t-0.5) / time advanced x(t+0.5) signals. And observe the change in the Fourier
spectra. Compare the results with the F.S of x(t).
5) State with reasons whether the following signals are periodic or aperiodic. For periodic
signals, find the period and state which of the harmonics are present in the series.
a) 3 sint + 2 sin3t b) 2+5sin4t + 4cos7t c) 2sin3t + 7cosπt
5t 6t t 
d) 7cosπt + 5sin2πt e) 3cos 2 t + 5 cos2t f) sin + 3 cos + 3 sin + 30 o 
2 5 7 
15t
g) sin 3t + cos h) (3sin2t + sin5t)2 i) (5sin2t)3
4
6) Find and sketch the Fourier Spectra for the following signals and repeat the exercises
1) to 4) for the same x(t)
1 e-t/10
A)

-4π -3π -2π -π 0 π 2π 3π 4π t (secs)

-1

x(t) t2
B)

-5 -4 -3 -2 -1 0 1 2 3 4 5 t (secs)

C) Signal variation replaced with t instead of t2 in the above signal B)


Discrete time signals:
Use of “fft” and “ifft” command, to find DTFS of a periodic discrete time signal.
➢ FFT(X) is the discrete Fourier transform (DFT) of vector X.
Compute and plot of the Exponential Fourier coefficients for a periodic signal:
For a signal shown in fig below,
x[n]
1

-32 0 32 n (integer)
In this case, Period No = 32 and Ωo = 2π/32 = π/16
1
Fourier coefficients, Dr, can be calculated as Dr = x[n]e − jr ( / 16 ) n
32 n =( 32 )
Method 1: By direct computation : Following MATLAB code can be used
No = 32; n= 0:No-1;
xn =[ones(1,5) zeros(1,23) ones(1,4)]; % signal definition for one period
for r=0:31,
xr(r+1) = sum(xn.*exp(-j*r*2*(pi/No)*n))/No;
end
r=n;
subplot(2,1,1); stem(r,real(xr),'k'); ylabel('absXr'); xlabel('r');
xr=round(1000*xr)/1000; %to avoid computational error
subplot(2,1,2); stem(r,angle(xr),'k'); ylabel('angleXr'); xlabel('r');

Method 2: By using fft command : Following MATLAB code can be used


xr1 = fft(xn)/No; % Make sure that number of samples of xn are 2
to the power some integer, as algorithm fft uses it that way.
subplot(2,1,1); stem(r,abs(xr1),'k'); ylabel('absXr'); xlabel('r');
subplot(2,1,2); stem(r,angle(xr1),'k'); ylabel('angleXr'); xlabel('r');

Exercises:
1) For the above example, plot Fourier series expanded signal x[n] vs. dicrete time n and
plot each (at least 5) Fourier series terms w. r. t. discrete time n, explicitly in the same
graph sheet, and observe the role of Amplitude and Phase Spectra in Wave shaping.
(Use inline functions if necessary)
2) Verify by plotting as well as analytically whether the following signals are periodic?
a) 3 sinn + 2 sin3n b) 2+5sin4πn + 4cos7πn c) 2sin3n + 7cosπn
15n
d) 7cosπn + 5sin2πn e) 3cos 2 πn+ 5 cos2πn f) sin 3n + cos
4
5n 6n  n 
g) sin + 3 cos + 3 sin + 30 o 
2 5  7 
3) Find the discrete time Fourier series (DTFS) and sketch their spectra |D r| and /_Dr for
0 ≤ r ≤ No-1 for the following periodic signal:
a) x[n] =4 cos2.4πn + 2sin3.2πn
b) x[n] =cos2.2πn + cos3.3πn
c) x[n] = 2cos3.2π(n-3)
d) x[n] e) x[n] an
3 1

-12 -6 -3 0 3 6 12 n integers -2No -No 0 No 2No n integers


4) Sketch the discrete time signal clearly, in the time domain, given the Fourier coefficients
of the signal as shown in the following table, by direct computation (from fundamental
equation). Also write an array of values of the signal in the time domain for one full
period. Express the signal in the time domain as Fourier series expansion either in the
compact trigonometric form or in the exponential form.
Dr : 0 -j0.8720 -j0.4330 +j0.3330 +j0.1440 -j0.2950
0 +j0.2950 -j0.1440 -j0.3330 +j0.4330 +j0.8720
Module -4 (Fourier Transform Analysis) –Part 2
Plots of standard functions
It is possible to plot/sketch the standard function viz. rectangle function,
triangle function, sinc function using inline OR sinc commands.
Following MATLAB code can be used :
% Generation of unit rectangular signal
p=inline('(t>=-(T/2))&(t<=(T/2))','t','T');
t= [-5:0.001:5]; T=2; plot(t,p(t,T),'r.-')
SINC functions : Sin(pi*x)/(pi*x) function.
sinc(x) : returns a matrix whose elements are the sinc of the elements of X, i.e.
y = sin(pi*x)/(pi*x) if x ~= 0
=1 if x == 0
Where, x is an element of the input matrix and y is the resultant output element.
Sketch the following functions
a) rect(t/2) b) Δ(3ω/100) c) rect((t-10)/8 d) sinc(πω/5)
e) sinc((ω/5)-2π) f) sinc(t/5) rect(t/10π)
F.T of Continuous time signals:
There is no MATLAB command which gives directly the Fourier Transform of any given
continuous time signal. MATLAB code can be written to compute the same using “sum”.
Modify the code supplied in Fourier series here and use it.
➢ Compute the Fourier transform of unit rectangle signal and sketch the spectra :
Manually derive the expression for Fourier Transform of the unit rectangle signal, and
use the result to plot the spectra.
Following MATLAB code can be used :
% Generation of Fourier transfom of rect signal : sinc function
w=linspace(-5*pi,5*pi,250);
x=inline('T.*sin(w*T/2)./(w*T/2)','w','T');
plot(w,x(w,T),'r.-')

Exercises:
➢ Discuss / Evaluate /comprehend, how the Fourier spectrum modifies, when the following
properties are applied to the above rectangle signal, [Use MATLAB, wherever necessary]
a) Scalar addition b) Scalar Multiplication c) Conjugation
d) addition of two different time domain signals e) Time shifting
f) Time scaling (compression, expansion, reversal g) Frequency shifting
h) Time Convolution i) Frequency convolution
➢ Compute the Fourier transform of unit triangle signal and sketch the spectra :
➢ Compute the Fourier transform of unit half triangle signal x(t) shown in figure P7-13
and sketch the spectra.
➢ Use the above exercise information, (F.T of standard signals, and properties) to find
the Fourier transform of the signals xi(t) (i =1,2,3,4,5) shown in figure P7-13 and
sketch the spectra.
➢ Use first principle and the above exercise information, (F.T of standard signals,
and properties) to find the Fourier transform of the signals shown in figure P7-14,
P7-15, P7-16 and sketch the spectra.
F.T of Discrete time signals: By using fft and fftshift command :
➢ Compute the Fourier transform of unit rectangle discrete signal and plot the spectra :
Following MATLAB code can be used
% Generation of unit rectangular discrete signal
n= [-8:8]; M=9
p=inline('((n>=-(M/2))&(n<=(M/2)))','n','M');
stem(n,p(n,M))
% Demonstration of getting Fourier spectra using fft command
N=1024;
% Generally this value is 2 to the power some integer: fft
algorithm uses it. If the periodicity is other than "2 to the
power some integer" there is a need of padding with zeroes in the
sequence to achieve this.
% vary this value to 512, 256, 128 and see
x=[ones(1,(M+1)/2) zeros(1,N-M) ones(1,(M-1)/2)];
X=fft(x);
omega = [-N/2:(N/2)-1]*2*pi/N; % to generate 512 samples of
frequency in –pi to pi region.
subplot(2,1,1);
plot([omega-2*pi omega omega+2*pi], fftshift(abs([X X X])),'r.-');
X=round(1000*X)/1000; %to avoid computational error
subplot(2,1,2);
plot([omega-2*pi omega omega+2*pi],fftshift(angle([X X X])),'k');
Exercises:
➢ Discuss / Evaluate /comprehend, how the Fourier spectrum modifies, when the following
properties are applied to the above rectangle signal, [Use MATLAB, wherever necessary]
b) Scalar addition b) Scalar Multiplication c) Conjugation
d) addition of two different time domain signals e) Time shifting
f) Time scaling (compression, expansion, reversal g) Frequency shifting
h) Time Convolution i) Frequency convolution
➢ Compute the Fourier transform of γnu[n] signal and sketch the spectra with γ = -0.8 :
➢ Compute the Fourier transform of the signals, shown in figure P9-12, P9-13, using
first principle (direct computation) OR using fft and the above exercise information,
(F.T of standard signals , and properties) and sketch the spectra.
➢ Compute the Fourier transform of triangle signal x(n) shown in fig. P9-16 a) and
sketch the spectra. Use the above exercise information, (F.T of standard signals, and
properties) to find the Fourier transform of the signals x(n) shown in fig. P9-16 b), c)
and d). Also sketch the spectra.
➢ Read the spectra, and find the inverse Fourier Transform of the following signals,
shown in figure P9-13, and P9-14, and sketch the discrete signal x(n). The signal is
represented in the Fourier domain (which is periodic function with 2π).
➢ Compute the Fourier transform of signals x(n) shown in figure P9-22 a) and sketch
the spectra. Use the above exercise information, (F.T of standard signals, and
properties) to find the Fourier transform of the signals x(n) shown in figure P9-22,
P9-26, P9-27. Also sketch the spectra.
%%%%% END %%%%%

You might also like