Lecture 4&5 MATLAB applications In Signal Processing · 2014. 4. 19. · MATLAB applications In...

Post on 01-Mar-2021

9 views 0 download

Transcript of Lecture 4&5 MATLAB applications In Signal Processing · 2014. 4. 19. · MATLAB applications In...

Lecture 4&5

MATLAB applications

In

Signal Processing

Dr. Bedir Yousif

Signal Analysis

Fourier Series and Fourier Transform

• Trigonometric Fourier Series

Where w0=2*pi/Tp and the Fourier coefficients an and bn are

determined by the following equations

Fourier Series Another Form of trigonometric Fourier Series

a0/2 is the dc component of the series and is the average value

of g(t) over a period.

The total power in g(t) is given by the Parseval’s equation:

And

Fourier Series • Example 1:

• Using Fourier series expansion, a square wave with a period of 2 ms, peak-to peak value of 2 volts and average value of zero volt can be expressed as

Where f0 = 500 Hz if a(t) is given as

Write a MATLAB program to plot a(t) from 0 to 4 ms at intervals of

0.05 ms and to show that a(t) is a good approximation of g(t).

Fourier Series

Solution • clear all

• f = 500; c = 4/pi; w0 = 2*pi*f;

• t=0:0.05e-3:4e-3;

• s=zeros(1,length(t));

• for n = 1: 12

• s = s+c*(1/(2*n - 1))*sin((2*n - 1)*w0*t);

• end

• plot(t,s)

• xlabel('Time, s')

• ylabel('Amplitude, V')

• title('Fourier series expansion')

Fourier Series Solution

Fourier Series Solution

Fourier Series Exponential Fourier Series

The coefficient cn is related to the coefficients an and bn

In addition, cn relates to An and φn of Equations

Fourier Series The plot of |cn| versus frequency is termed the

discrete amplitude spectrum or the line spectrum.

A similar plot of ∠cn versus frequency is called the

discrete phase spectrum

If an input signal xn(t)

passes through a system with transfer function H(w), then the

output of the system yn(t) is

Fourier Series

If an input signal xn(t) written in complex F.S

the response at the output of the system is

Fourier Series Example 2

For the full-wave rectifier waveform shown in Figure,

the period is 1/60 s and the amplitude is 169.71 Volts.

(a) Write a MATLAB program to obtain the exponential

(b) Fourier series coefficients cn for n = 0,1, 2, .. , 19

(b) Find the dc value.

(c) Plot the amplitude and phase spectrum.

Fourier Series Solution

% generate the full-wave rectifier waveform

f1 = 60;

inv = 1/f1; inc = 1/(80*f1); tnum = 3*inv;

t = 0:inc:tnum;

g1 = 120*sqrt(2)*sin(2*pi*f1*t);

g = abs(g1);

N = length(g);

% obtain the exponential Fourier series coefficients

num = 20;

for i = 1:num

for m = 1:N

cint(m) = exp(-j*2*pi*(i-1)*m/N)*g(m);

Fourier Series Solution end

c(i) = sum(cint)/N;

end

cmag = abs(c); cphase = angle(c);

%print dc value

disp('dc value of g(t)'); cmag(1)% c0

% plot the magnitude and phase spectrum

f = (0:num-1)*60;

subplot(121), stem(f(1:5),cmag(1:5))

title('Amplitude spectrum')

xlabel('Frequency, Hz')

subplot(122), stem(f(1:5),cphase(1:5))

title('Phase spectrum')

xlabel('Frequency, Hz')

Fourier Series Spectrum Result

Fourier Series Result

dc value of g(t)

ans =

107.5344

Fourier Series

Example .3

The periodic signal shown in Figure

(i) Show that its exponential Fourier series expansion can be

expressed as

(ii) Using a MATLAB program, synthesize g(t) using 20 terms, i.

Fourier Series

Solution

Fourier Series Solution % synthesis of g(t) using exponential Fourier series expansion

dt = 0.05;

tpts = 8.0/dt +1;% No. of points on time axis

cst = exp(2) - exp(-2);

for n = -10:10

for m = 1:tpts

g1(n+11,m) = ((0.5*cst*((-1)^n))/(2+j*n*pi))*(exp(j*n*pi*dt*(m-1)));

end

end

for m = 1: tpts

g2 = g1(:,m);

g3(m) = sum(g2);

end

g = g3';

t = -4:0.05:4.0;

plot(t,g)

xlabel('Time, s')

ylabel('Amplitude'); title('Approximation of g(t)')

Fourier Series Solution

Approximation of g(t) .

Fourier Series Fourier Series for Several Periodic Signals

Fourier transform

Fourier Transform formula:

Inverse Fourier Transform formula:

If g(t) is continuous and nonperiodic, then G(f) will be continuous

and periodic. However, if g(t) is continuous and periodic,

then G(f) will discrete and nonperiodic; that is

Fourier transform

Complex exponential Fourier coefficient:

Properties of Fourier transform

1- Linearity

Ag1 (t) +bg2 (t) ⇔ aG1(f) + bG2(f)

Where a and b are constants

2- Time scaling

Properties of Fourier transform

3- Duality

G(t) ⇔ g(−f )

4- Time shifting

g(t−t )⇔ G( f ) exp(−j2Π ft )

5- Frequency Shifting

exp(j2 fc t)g(t) ⇔ G(f -fc )

6- Differentiation in the time domain

Properties of Fourier transform

7- Integration in the time domain

8- Multiplication in the time domain

9- Convolution in the time domain

Properties of Fourier transform

7- Integration in the time domain

8- Multiplication in the time domain

9- Convolution in the time domain

Thanks