+ All Categories
Home > Documents > Basic Engineering Mathematics with Matlab

Basic Engineering Mathematics with Matlab

Date post: 19-Jan-2016
Category:
Upload: oria
View: 68 times
Download: 13 times
Share this document with a friend
Description:
Basic Engineering Mathematics with Matlab. Professor Long-Wen Chang National Tsing Hua University Hsinchu, Taiwan. Why engineering mathematics is very important ? It is very important for the applications of signal analysis. The applications include - PowerPoint PPT Presentation
Popular Tags:
193
Basic Engineering Mathematics with Matlab Professor Long-Wen Chang National Tsing Hua University Hsinchu, Taiwan
Transcript
Page 1: Basic Engineering Mathematics with Matlab

Basic Engineering Mathematics with Matlab

Professor Long-Wen Chang

National Tsing Hua University

Hsinchu, Taiwan

Page 2: Basic Engineering Mathematics with Matlab

Why engineering mathematics ismathematics isvery important ?very important ?

It is very important for the applications of It is very important for the applications of signal analysis. The applications includesignal analysis. The applications includeelectrical engineering, computer electrical engineering, computer engineering, engineering, civil engineering, mechanical engineering civil engineering, mechanical engineering and physics etc..and physics etc..

Page 3: Basic Engineering Mathematics with Matlab

Outlines

• One dimensional continuous time signals

• One dimensional continuous systems

• Linear ODE in the time domain

• The Laplace transform

• Linear ODE in the Laplace transform domain

• Fourier transform

• Analog filters

Page 4: Basic Engineering Mathematics with Matlab

Why a learning tool is needed ?

• To learn efficiently and effectively

• To learn by doing simulations

Page 5: Basic Engineering Mathematics with Matlab

The learning tools

• Low cost and high speed multimedia computers are available.

• Mathematical Software such as Matlab, Mapel, Mathematica is available.

• Microsoft power point is very good for presentation.

Page 6: Basic Engineering Mathematics with Matlab

Why MATLAB is used ?

• It can use a simple instruction to compute a very complex mathematical function.

• It provides high resolution two dimensional and three dimensional graphic plot functions for signal analysis.

Page 7: Basic Engineering Mathematics with Matlab

Why MATLAB is used ?

• It can play the sound and display an image in a personal computer or a workstation locally or from the computer network with the X window interface.

• MATLAB programs are portable in many computer systems.

Page 8: Basic Engineering Mathematics with Matlab

Why MATLAB is used ?

• It provides interface with the programming language C to enhance its programming ability and execution speed.

• We can write a simple program easily to simulate an application which might takes many hours or many days in C or Fortran.

Page 9: Basic Engineering Mathematics with Matlab

Chapter 1One Dimensional Continuous

Time Signals

Page 10: Basic Engineering Mathematics with Matlab

Outline

• What are signals ?

• What are analog signals ?

• What are physical signals ?

• Bounded signals with finite energy

• Linear convolution of two analog signals

Page 11: Basic Engineering Mathematics with Matlab

Introduction

What are Signals ?

In a real world a lot of physical events can be described as signals.

Page 12: Basic Engineering Mathematics with Matlab

Examples

Ultrasound signals are helpful for medicine;

Seismic signals are used to detect the earthquake;

Electric signals are used to operate electric devices;

Radio signals are used for communication.

Page 13: Basic Engineering Mathematics with Matlab

Examples

There are also other signals that are very useful.

Among them, audio signals and visual signals are the most important for human beings.

Audio signals can be heard while visual signals can be seen.

Page 14: Basic Engineering Mathematics with Matlab

What are Multimedia signals?

• Audio

• Video

• Image

• Text

• Graphics

Page 15: Basic Engineering Mathematics with Matlab

Figure 1.1 shows a sound wave

Figure 1.2 shows a mandrill image.

Page 16: Basic Engineering Mathematics with Matlab

Figure 1.1: A sound wave

Page 17: Basic Engineering Mathematics with Matlab

Adam.wave

Page 18: Basic Engineering Mathematics with Matlab

Phantom of Opera

• 8 bits, 44.1 Hz (Mono)

• '8 bits, 22.05Hz(Mono)

• '8 bits, 44.1 Hz(Stereo)

• ‘16 bits, 22.05 Hz(Mono)

Page 19: Basic Engineering Mathematics with Matlab

How to play a .wav file ?

• [y,fs]=wavread('adam.wav');

• t=(1:length(y))/fs;

• fr=int2str(fs);

• plot(t,y);

• title(['Sample frequency= ',fr,'(Hz)']);

• xlabel('Time');

• sound(y,fs);

Page 20: Basic Engineering Mathematics with Matlab

Figure 1.2: A mandrill image

Page 21: Basic Engineering Mathematics with Matlab

A 256 gray level image

Page 22: Basic Engineering Mathematics with Matlab

A binary image

Page 23: Basic Engineering Mathematics with Matlab
Page 24: Basic Engineering Mathematics with Matlab

Physical Signals

In a physical world, signals are real values with finite energy.

Mathematical Signals

In a mathematical world, signals can be complex valued and have infinite energy.

Page 25: Basic Engineering Mathematics with Matlab

Definition 1 : An one dimensional real-valued analog signal is defined as a piecewise continuous function Rf t Rbat ,

tf

,where. Its magnitude is defined as its absolute value

Page 26: Basic Engineering Mathematics with Matlab

Traditionally, analog signals means signals that are continuous in both time and magnitude.

Continuous time signals means analog signals.

What are analog signals ?

Page 27: Basic Engineering Mathematics with Matlab

Analog Signals

• Sinusoidal signals

• DC signals

• Unit step signals

• rectangular signals

• triangular signals

• Exponential signals

• square signals

Page 28: Basic Engineering Mathematics with Matlab

Analog signals (continued)

• Sgn(t)

• Cosh(t)

• Sinh(t)

• Sinc(t)

Page 29: Basic Engineering Mathematics with Matlab

Analog Signals(Continued)

• Nonperiodic signals

• Periodic signals

• Time limited signals

• non-time limited signals

Page 30: Basic Engineering Mathematics with Matlab

Definition 2 : Assume that a > 0. A sinusoidal signals is defined as an analog signal

wtatf sin (1.1)

Where a is the amplitude and is the phase shift and w is the angular frequency given as

sec/2

radiansT

(1.2)

Page 31: Basic Engineering Mathematics with Matlab

is called the cycle frequency in cycles/second.

A cycle per second is also called a hertz (Hz).

T is the period of the signal

T

1

Page 32: Basic Engineering Mathematics with Matlab

How to characterize a sinusoidalsignals?

• Amplitude

• Frequency

• Phase shift

Page 33: Basic Engineering Mathematics with Matlab

The signal sin(wt + ) is a translated version of sin(wt).

Similarly, f(t+a) is a translated version of f(t).

Page 34: Basic Engineering Mathematics with Matlab

Example 1 : The signals a cos(wt) and a sin(wt) are continuous cosine and sine signals. They both have the amplitude a and the frequency w.

).cos()2

sin( wtwt

Figure 1.3(a) and Figure 1.3(b) shows a cosine signal cos(2t) and a sine signal sin(2t).

Their frequencies are 1 cycle/sec(Hz) and their amplitudes are 1, respectively.

Note that

Page 35: Basic Engineering Mathematics with Matlab

Similarly, an electric voltage source f(t) = 110 * sin(120*t) has 60 Hz and it maximum voltage is 110 volts.

Figure 1.4 shows sin(2t), sin(10t) and sin(20t).

Their frequencies are 1 cycle/sec, 5 cycles/sec and 10 cycles/sec,respectively. As the frequency increases the signal oscillates rapidly.

Page 36: Basic Engineering Mathematics with Matlab

What are the frequencies of thefollowing signals ?

• sin(2t)

• sin(20t)

• sin(20t)

• sin(200t)

• sin(2000t)

Page 37: Basic Engineering Mathematics with Matlab

Conventionally, cosine signals and sine signals with nonzero frequency are called AC signals. If their frequencies are large they are referred as high frequency signals;

otherwise they are referred as low frequency signals.

A signal with zero frequency is called a DC signal.

Page 38: Basic Engineering Mathematics with Matlab

Continuous plot

• % Generate a 1 Hz cosine function sampled by T sec.

• T=0.02;

• t = -1 :T:1;

• y = cos(2 * pi * t);

• plot(t,y); xlabel('t');

• ylabel('f(t)');set(gca, 'Ylim',[-2, 2]);

Page 39: Basic Engineering Mathematics with Matlab

)2( tCOS

Page 40: Basic Engineering Mathematics with Matlab

Figure 1.3: (a)cos(2t)

Page 41: Basic Engineering Mathematics with Matlab

(b) sin(2t)

Page 42: Basic Engineering Mathematics with Matlab

(c) f(t)=1

Page 43: Basic Engineering Mathematics with Matlab

Figure 1.4: (a)sin(2t)

Page 44: Basic Engineering Mathematics with Matlab

(b) sin(10t)

Page 45: Basic Engineering Mathematics with Matlab

(c) sin(20t)

Page 46: Basic Engineering Mathematics with Matlab

Definition 3 : A DC signal is defined as f(t) = c, where cR and - <t< . Figure 1.3(c) shows a DC signal with c = 1 and .22 t

A DC voltage source can be considered as a sinusoidal voltage source with zero frequency.

Page 47: Basic Engineering Mathematics with Matlab

Definition 4 : An real valued exponential signal is defined as ate , where aR.

Figure 1.5(a) and 1.5(b) shows two exponential signals with a = 1 and a = -1 for - 1t 1. If a > 0 the signalate increase exponentially to ;

ate decreases exponentially to 0.If a < 0 the signal

Page 48: Basic Engineering Mathematics with Matlab

Figure 1.5: (a) A decreasing exponential signal

te

Page 49: Basic Engineering Mathematics with Matlab

(b) An increasing exponential signal

te

Page 50: Basic Engineering Mathematics with Matlab

Definition 5 : A unit step signal u(t) is defined as

.,0

;0,1)(

otherwise

Rtiftu (1.3)

It has a discontinuity at t = 0. Figure 1.7 shows a unit step signal for - 10 t 10.

Page 51: Basic Engineering Mathematics with Matlab

Since T can be used to measure the decay of the exponential signal it is called the time constant.

For example, the signal

)()( / tuCetf Tthas the value 0 for t < 0, the peak value C at t = 0,

1Ce 2Ce3Ce

= 0.3679C at t = T, = 0.1353C at t = 2T= 0.0498C at t = 3T. and

Page 52: Basic Engineering Mathematics with Matlab

Figure 1.7: A unit step signal

Page 53: Basic Engineering Mathematics with Matlab

Example 2 : Figure 1.6 shows a electric system with an ideal 9 volt battery and a switch. If the switch is close at t = 0 the battery supplies the electricity to the system. The ideal DC voltage source can be considered as

)]()([9)( Ltututf (1.4)

where L is the life time of the battery.

Page 54: Basic Engineering Mathematics with Matlab

9V

switch

electricdevice

Figure 1.6: An electric system with a 9 volt battery

Page 55: Basic Engineering Mathematics with Matlab

Definition 6 : A rectangular signal rec(t) is defined as

It can also written as

.,0

;2/1,1)(

otherwise

tiftrec

)2

1()

2

1()( tututrec

(1.5)

(1.6)

Page 56: Basic Engineering Mathematics with Matlab

Figure 1.8: A rectangular signal

Page 57: Basic Engineering Mathematics with Matlab

Definition 7 : A triangular signal tri(t) is defined as

.,0

;1,1)(

otherwise

tiftttri (1.7)

It can also written as

)1()1()(2)1()1()( tutttututttri (1.8)

Page 58: Basic Engineering Mathematics with Matlab

Figure 1.9: A triangular signal

Page 59: Basic Engineering Mathematics with Matlab

Definition 8 : The signal sinc(t) is defined as

t

ttc

)sin(

1)(sin (1.9)

, if t = 0;

, otherwise.

Page 60: Basic Engineering Mathematics with Matlab

Figure 1.10 shows the signal sinc(t) for - 10 t 10. It has a peak value 1 at t = 0 and two valley values at t = - 3/2,3/2. The signal between - 3/2 t 3/2 is called the main lobe. Other signals with similar wave shape are called side lobes. For example, the signals in 3/2 t 5/2 and 5/2 t 7/2 are side lobes..

Page 61: Basic Engineering Mathematics with Matlab

MATLAB program

T = - 10:0.01:10;f = sinc(t);plot(t,f);xlabel(‘t’);ylabel(‘f(t)’);

Page 62: Basic Engineering Mathematics with Matlab

Figure 1.10: A sinc signal

Page 63: Basic Engineering Mathematics with Matlab

Definition 9 : The signal sgn(t) is defined as

1

1)sgn(t (1.10)

,if t 0;

,if t < 0;

Page 64: Basic Engineering Mathematics with Matlab

Figure 1.11: A sgn(t) signal

Page 65: Basic Engineering Mathematics with Matlab

Definition 10 : The signal cosh(t) is defined as

2/)( tt ee

Page 66: Basic Engineering Mathematics with Matlab

Definition 11 : The signal sinh(t) is defined as 2/)( tt ee

Page 67: Basic Engineering Mathematics with Matlab

Figure 1.12: (a) A cosh(t) signal

Page 68: Basic Engineering Mathematics with Matlab

(b) A sinh(t) signal

Page 69: Basic Engineering Mathematics with Matlab

Definition 12 : A real-values analog signal f(t) is called a time limited signal if f(t) = 0 outside the region [a,b]R.

Page 70: Basic Engineering Mathematics with Matlab

Periodic signals

• Period

• Frequency

• Duty cycle

• Root mean squared value

• DC value

Page 71: Basic Engineering Mathematics with Matlab

Definition 13 : A real-values analog signal f(t) is called a periodic signal if f(t+P) = f(t), where P is its period.

Page 72: Basic Engineering Mathematics with Matlab

Definition 14 : The duty cycle of a periodic signal f(t) with the period T is defined as

where is the time duration of the positive cycle.

T

tD 0 (1.11)

0t

Page 73: Basic Engineering Mathematics with Matlab

Definition 15 : The root mean square ( rms ) value of a periodic signal f(t) with the period T is defined as

2/1

0

2 )(1

T

rms dttfT

f (1.12)

Page 74: Basic Engineering Mathematics with Matlab

Definition 16 : The dc value of a periodic signal f(t) is defined as

T

dc dttfT

f0

)(1

(1.13)

Page 75: Basic Engineering Mathematics with Matlab

Example 3 : The signals of acos(wt) and asin(wt) are periodic with period 2/w.

They both have dc values 0 and 50 duty cycles.

Page 76: Basic Engineering Mathematics with Matlab

Definition 17 : A square wave is a periodic signal f(t+T) = f(t), where

.,

;0,)(

0

0

TtifTa

Ttifatf (1.14)

Page 77: Basic Engineering Mathematics with Matlab

Example 4 : The signal

.15.0,1

;5.00,1)(

tif

tiftf (1.15)

is a square wave with peaks of 1, period P = 1 and 50 duty cycle.

It is shown in Figure 1.13(a). It is plotted by the following MATLAB program.

Page 78: Basic Engineering Mathematics with Matlab

<MATLAB Program:>t = - 2:0.01:2;y = square(2 * pi * t,50);plot(t,y);xlabel(‘t’);ylabel(‘f(t)’);set(gca,’Ylim’,[ - 2,2]);set(gca,’Xlim’,[ - 2,2]);

Page 79: Basic Engineering Mathematics with Matlab

Figure 1.13: (a) A periodic square signal

Page 80: Basic Engineering Mathematics with Matlab

(b) A period sawtooth signal

Page 81: Basic Engineering Mathematics with Matlab

Definition 18 : A triangular wave is a periodic signal f(t+T) = f(t) , where

.),()(

0,)(

00102

;01

TtifTaTmTtm

Ttifatmtf (1.16)

where a, 1m and 2m are constant.

Page 82: Basic Engineering Mathematics with Matlab

Example 5 : The signal

.15.0,34

;5.00,14)(

tift

tifttf (1.17)

is a triangular wave with peaks of 1 and a period P = 1 and, 50 duty cycle.

It is shown in Figure1.13.

Page 83: Basic Engineering Mathematics with Matlab

t = - 2:0.01:2;x = sawtooth(2 * pi * t,0.5);plot(t,x);xlabel(‘t’);ylabel(‘f(t)’);set(gca,’Ylim’,[ - 2,2]);set(gca,’Xlim’,[ - 2,2]);

Page 84: Basic Engineering Mathematics with Matlab

Definition 19 : The dilation of a signal f(t) is defined as f(at), a < 1. The contraction of a signal f(t) is defined as f(at), a > 1.

Page 85: Basic Engineering Mathematics with Matlab

Example 6 : Figure 1.14(a) show sinc(0.5t). It is a dilated version of sinc(t) shown in Figure 1.14(b). Figure 1.14(c) shows sinc(2t). It is a contracted version of sinc(t).

Page 86: Basic Engineering Mathematics with Matlab

Figure 1.14: (a) a = 0.5

Page 87: Basic Engineering Mathematics with Matlab

(b) a = 1

Page 88: Basic Engineering Mathematics with Matlab

(c) a = 2

Page 89: Basic Engineering Mathematics with Matlab

Example 7 : The function tri(t) is a very special function such that

which is illustrated in Figure 1.15.

2

)12()2(

2

)12()(

ttrittri

ttrittri (1.18)

Page 90: Basic Engineering Mathematics with Matlab

Figure 1.15:Illustration of rec(t) = rec(2t+1)/2 + rec(2t-1) + rec(2t-1)/2

Page 91: Basic Engineering Mathematics with Matlab

Definition 20 : The one dimensional impulse function (t) in the continuous time is a Direct delta function that has the following three properties:

0)(t

, if t = 0;

, otherwise.(1.19)

).0()()(

.0,1)(

fdttft

dtt

(1.20)

(1.21)

Page 92: Basic Engineering Mathematics with Matlab

/

0

sin

1

0

2

lim)(.4

lim)(.3

)(*lim)(.2

)]()([lim)(.1

te

L

twt

w

a

LL

t

t

atrecat

Ltutut

The Direct delta function (t) is a very special function. It can be looked as a limit of the following functions:

Page 93: Basic Engineering Mathematics with Matlab

Fig.16 shows the case of L=1,2

Fig.17 shows the cases of a = 0.5,1,2

Fig.18 shows the case of w=1,10

Fig.19 shows the cases of =1,10

Page 94: Basic Engineering Mathematics with Matlab

Figure 1.16: 1/L[u(t)-u(t-L)] (a) L = 1

Page 95: Basic Engineering Mathematics with Matlab

(b) L = 2

Page 96: Basic Engineering Mathematics with Matlab

Figure 1.17: rec(at) (a) a = 0.5

Page 97: Basic Engineering Mathematics with Matlab

(b) a = 1

Page 98: Basic Engineering Mathematics with Matlab

(c) a = 2

Page 99: Basic Engineering Mathematics with Matlab

Figure 1.18: Sinc functions with (a) w=1

Page 100: Basic Engineering Mathematics with Matlab

(b) w=10

Page 101: Basic Engineering Mathematics with Matlab

Figure 1.19: Gaussian functions with (a)=1

Page 102: Basic Engineering Mathematics with Matlab

(b) =2

Page 103: Basic Engineering Mathematics with Matlab

Example 8 : Prove that

)].()([lim)( 1

0Ltutut LL

It is easy to know the following equations are true.

1)]()([lim

0)]()([lim

1

0

1

0

dtLtutu

Ltutu

LL

LL

,if t = 0;

,otherwise.(1.22)

(1.23)

Page 104: Basic Engineering Mathematics with Matlab

)0()lim)(0()])()([lim)(( 1

0

1

0fLfdtLtututf LLLL

(1.24)

Therefore, ).()]()([lim 1

0tLtutuLL

As shown in Figure 1.20 we can write

Page 105: Basic Engineering Mathematics with Matlab

Figure 1.20: Illustraction of

)0()])()([)(lim( 10 fdtLtututf LL

Page 106: Basic Engineering Mathematics with Matlab

Physical Signals

• Bounded

• finite energy

• How to compute the energy of a signal ?

Page 107: Basic Engineering Mathematics with Matlab

Definition 21 : A real-valued analog signal f(t) is called bounded if there exists a positive finite value K such that

Ktf )( (1.25)

Page 108: Basic Engineering Mathematics with Matlab

Definition 22 : The energy of a real-valued analog signal f(t) is defined as

dttfE )(2

(1.26)

Page 109: Basic Engineering Mathematics with Matlab

Definition 23 : A real-valued analog signal f(t) is called square integrable if it has a finite energy.That is,

dttfE )(2

(1.27)

Page 110: Basic Engineering Mathematics with Matlab

Example 9 : The rectangular signal rec(t) is square integrable because its energy<Manual Solution:>f = ‘1’;int(f,’t’, - 1/2,1/2)ans =

2

1

21

1)(2 dttrec (1.28)

Page 111: Basic Engineering Mathematics with Matlab

Example 10 : The cosine signal (cos t)u(t) is not square integrable<Manual Solution:>

dtt

dtttu

0

2

2

2cos1))((cos

)

4

2sin

2(lim

2

2cos1lim

0

TT

dtt

T

T

T

(1.29)

Page 112: Basic Engineering Mathematics with Matlab

<MATLAB Solution:>f = ‘cos(t)^2’;int(f,’t’,0,Inf)

ans =1/2*inf

Page 113: Basic Engineering Mathematics with Matlab

Example 11 : The signal

)(tue tis square

dttue t

2))((

2

1

)2/1( 0

0

2

t

t

e

dte

(1.30)

integrable.<Manual Solution:>

Page 114: Basic Engineering Mathematics with Matlab

<MATLAB Solution:>f = ‘exp( - 2*t)’;g = int(f,’t’,0,Inf);pretty(g);

1/2

Page 115: Basic Engineering Mathematics with Matlab

Example 12 : The signal

)(cos ttue t

)(sin ttue t and

are square integrable. It is known)(tue t

is square integrable from theprevious example. Since

)()()(cos 222 tuetute tt

the signal )(cos ttue t is square integrable.

)()()(sin 222 tuetute tt

(1.31)

(1.32)

Similarly, we have

that

Page 116: Basic Engineering Mathematics with Matlab

Therefore, the signal )(sin ttue t is square

dttute t 2)]()cos([

0

221

0

221

0 212

)2cos(

)]2cos(1[

dttedte

dtte

tt

t

(1.33)

integrable. In fact,

Page 117: Basic Engineering Mathematics with Matlab

We can easily prove that

4

1

2

10

2 dte t

and

)1(2

1)2cos(

20

2

dtte t

(1.34)

(1.35)

From the calculation above we obtain

Page 118: Basic Engineering Mathematics with Matlab

(1.36)

)1(4

2

)1(4

1

4

1)]()cos([

2

2

22

tute t

(1.37)

Page 119: Basic Engineering Mathematics with Matlab

<MATLAB Proof:>f = ‘(exp( - t)*cos(w*t))^2’;int(f,’t’,0,Inf)

ans =

1/4*(2+w^2)/(1+w^2)

Page 120: Basic Engineering Mathematics with Matlab

Definition 24 : A real-valued analog signal f(t) is called absolute integrable if

dttf )( (1.38)

Page 121: Basic Engineering Mathematics with Matlab

Example 13 : The retangular signal f(t) is absolute integrable because

1)( 21

21

dttrec (1.39)

Page 122: Basic Engineering Mathematics with Matlab

Definition 25 : The convolution of two real valued functions f(t) and g(t) is defined as

daatgaftgtf )()()(*)( (1.40)

Page 123: Basic Engineering Mathematics with Matlab

Example 14 : Figure 1.21(a) shows f(t) = u(t)- u(t - L). The convolution of f(t) and itself is

.,0

;2,2

;0,

)(*)(

otherwise

LtifLtL

Ltift

tftf (1.41)

There are four cases as shown in Figure 1.22:

Page 124: Basic Engineering Mathematics with Matlab

(Case 1:) If t < 0 there is no overlapping area for f(a) and f(t - a).Thus,

0

)()()(*)(

daatfaftftf

(1.42)

Page 125: Basic Engineering Mathematics with Matlab

(Case 2:) If 0t L then the overlapping area for f(a) and f(t - a) in the range [0,t]. Thus,

t

da

daatfaftftf

t

0

)()()(*)(

(1.43)

Page 126: Basic Engineering Mathematics with Matlab

(Case 3:) If Lt 2L then the overlapping area for f(a) and f(t - a) in the range [t-L,L]. Thus,

tL

da

daatfaftftf

L

Lt

2

)()()(*)(

(1.44)

Page 127: Basic Engineering Mathematics with Matlab

(Case 4:) If 2L < t there is no overlapping area for f(a) and f(t - a). Thus,

0

)()()(*)(

daatfaftftf

(1.45)

Page 128: Basic Engineering Mathematics with Matlab

Figure 1.21: (a) f(t)=u(t)-u(t-L)

Page 129: Basic Engineering Mathematics with Matlab

(b) Convolution of two identical signals f(t) and f(t)

Page 130: Basic Engineering Mathematics with Matlab

f(a)

0

f(a)

0

f(t-a)

0

f(t-a)

0

1

L

1

Lt-L+t

1

-L

1

t-L

(a) (b)

Figure 1.22: Illustration the convolution off(t) = u(t) - u(t-L) and f(t) (a) Case 1 (b) Case 2

Page 131: Basic Engineering Mathematics with Matlab

f(a)

0

f(a)

0

f(t-a)

0 0

1

L

1

L

1

(c) (d)

-t+L t-L

1

t-L L t L 2L

(c) Case 3 (d) Case 4

Page 132: Basic Engineering Mathematics with Matlab

Figure 1.21(b) shows the result of the linear convolution.

Page 133: Basic Engineering Mathematics with Matlab

The linear convolution is one of the most important computations in the linear time invariant system.

If an analog signal is processed by a linear system the output is the convolution of the impulse response of the system and the input. In a real world signals are real valued;

Page 134: Basic Engineering Mathematics with Matlab

In a mathematical world such as in Fourier transform domain we might deal with a complex valued signal.

For this reason, we have the following definitions:

Page 135: Basic Engineering Mathematics with Matlab

Definition 26 : A complex-valued analog signal

)()()( 21 tjftftf

where )(1 tf and )(2 tf are real-valued analog signals.

Page 136: Basic Engineering Mathematics with Matlab

Definition 27 : The magnitude of a complex-valued analog signal )()()( 21 tjftftf is defined as

which is also its absolute value.

))()(()( 22

21 tftftf (1.46)

Page 137: Basic Engineering Mathematics with Matlab

Example 15 : The signal

)sin()cos( tjte jwt is a complex-valued analog signal with the radian frequency . Its magnitude is

1)(sin)(cos 22 tte jwt (1.47)

Page 138: Basic Engineering Mathematics with Matlab

Example 16 : The signal

)2sin()2cos( tjte jwt is a complex-valued analog signal with the frequency 1Hz or the radian frequency 2.

Page 139: Basic Engineering Mathematics with Matlab

Example 17 : Figure 1.23-1.25 show three complex value signals 11, teat and a =

tje 2

. It oscillates with 1 Hz from - and . Figure tje 21

signal oscillates with 1 Hz and decreasesexponentially to 0. Similarly, Figure 1.25 shows

tje 21

oscillates and increase exponentially to .

- 1+j2, j2, or 1+j2. Figure 1.24 shows

1.23 shows in [ - 1,1] and [- 5,5]. The

in [ - 1,1] and [ - 5,5]. The signal

Page 140: Basic Engineering Mathematics with Matlab

Figure 1.23: in the range (a) [-1,1]tje )21(

Page 141: Basic Engineering Mathematics with Matlab

(b) [-5,5]

Page 142: Basic Engineering Mathematics with Matlab

Figure 1.24:

tje 2

Page 143: Basic Engineering Mathematics with Matlab

Figure 1.25: in the range (a) [-1,1]tje )21(

Page 144: Basic Engineering Mathematics with Matlab

(b) [-5,5]

Page 145: Basic Engineering Mathematics with Matlab

Definition 28 : The signal

tae t cos and

tae t sin, >0 are called damped sinusoids.

Page 146: Basic Engineering Mathematics with Matlab

Definition 29 : The energy of a complex-valued analog signal f(t)C is defined as

dttftfE *)()( (1.48)

where*)(tf is conjugate of )(tf

Page 147: Basic Engineering Mathematics with Matlab

Theorem 1 : The energy of

)()( tue tjwa

, is equal to<Manual Proof:>

a2

1

a

ea

dtedttuetue

at

attjwatjwa

2

12

1

))())(((

02

0

2*)()(

(1.49)

Page 148: Basic Engineering Mathematics with Matlab

<MATLAB Proof:>f = ‘exp(( - a+j*w)*t)*exp(( - a - j*w)*t)’;energy = int(f,’t’,0,Inf)energy = limit( - 1/2/exp(t*a)^2/a+1/2/a,t = inf,left)pretty(energy)

aatait

t 2

1

)exp(2

1lim

2inf

Page 149: Basic Engineering Mathematics with Matlab

MATLAB Programming

Page 150: Basic Engineering Mathematics with Matlab

1.MATLAB is very suitable for signal processing. MATLAB programs is portable to any computer if it is installed with MATLAB and its tool-boxes. Once you initiate MATLAB software you see a prompt >> to indicate that MATLAB is waiting for your command. Each command can be interpreted as soon as you type in. To understand a command you can type help name, where name is the name of a command. For example,

Page 151: Basic Engineering Mathematics with Matlab

>> help sinc

MATLAB will output the information about the sinc function. A variable in MATLAB can be a scalar, a vector or a matrix; For example,

>> x = 3 x = 3 >> y = 1:5 y =

Page 152: Basic Engineering Mathematics with Matlab

1 2 3 4 5 >> z=[1:3;4:6;7:9] z = 1 2 3 4 5 6 7 8 92.To understand the variables in the MATLAB environment you can type whos to access their information. For example,

Page 153: Basic Engineering Mathematics with Matlab

>> whos Name Size Elements Bytes Density Complex

x 1 by 1 1 8 Full No y 1 by 5 5 40 Full No z 1 by 9 9 72 Full No

Grand total is 15 elements using 120 bytes

3.MATLAB provides the following arithmetic operators to compute the arithmetic operations between a and b. There are several cases that

Page 154: Basic Engineering Mathematics with Matlab

the following operations are valid: (a) both a and b are scalar. (b) a is a vector or a matrix and b is scalar. (c) both a and b are vectors or matrixes with the same dimension.

Notation Functiona+b plusa-b minusa*b multiplicationa/b divisiona=b assignment

Page 155: Basic Engineering Mathematics with Matlab

For example,

>> a = 5; >> b = 2; >> a+b ans = 7

>> z z = 1 2 3 4 5 6 7 8 9

Page 156: Basic Engineering Mathematics with Matlab

>> a+z ans = 6 7 8 9 10 11 12 13 14

>> a*z ans = 5 10 15 20 25 30 35 40 45

Page 157: Basic Engineering Mathematics with Matlab

>> z*z ans = 30 36 42 66 81 96 102 126 150

>> z^2 ans = 30 36 42 66 81 96 102 126 150

Page 158: Basic Engineering Mathematics with Matlab

4.MATLAB provides the following logic operators to compute the logic operations between a and b, where a and b must have the same dimension.

a==b equala< >b not equala&b logic ANDa|b logic ORa logic NOT

>> a = [0 1] a = 0 1

Page 159: Basic Engineering Mathematics with Matlab

>> b = ~a b = 1 0 >> a & b ans = 0 0 >> a | b ans = 1 1 >> a == b ans = 0 0

Page 160: Basic Engineering Mathematics with Matlab

5.MATLAB provides the following array operators to compute the array operations between a and b, where a and b must have the same dimension.

a.*b array multiplicationa./b array division

a = 1 2>> b = [2,3]b = 2 3

Page 161: Basic Engineering Mathematics with Matlab

>> a .^ b ans = 1 8 >> a .* b ans = 2 6 >> a ./b ans = 0.5000 0.6667

The following program plots 1 Hz cosine signalcos(2t). Actually, it’s digital signal. However,we can look it as a real-value analog signal.

Page 162: Basic Engineering Mathematics with Matlab

Suppose the filename of the program is cos1.m you type cos1 to execute the program. For example, >> cos1 t = - 1:0.01:1; y = cos(2 * pi * t); fig; plot(t,y); xlabel(‘t’); ylabel(‘f(t)’); set(gca, ‘Ylim’,[- 2,2]); print -deps cos1

Page 163: Basic Engineering Mathematics with Matlab

6.MATLAB provides the following instructions for triangular, hyperbolic, exponential and logarithmic functions,

Page 164: Basic Engineering Mathematics with Matlab

f(t) Function of the signalcos(t) a cosine signalsin(t) a sine signaltan(t) a tangent signalacos(t) an inverse cosine signalasin(t) an inverse sine signalatan(t) an inverse tangent signalatan2(t) a four quadrant inverse tangent signalexp(t) an exponential signallog(t) a natural logarithm signallog10(t) a common logarm signalsqrt(t) a square signalcosh(t) a hyperbolic cosine signalsinh(t) a hyperbolic sine signaltanh(t) a hyperbolic tangent signalacosh(t) an inverse hyperbolic cosine signalasinh(t) an inverse hyperbolic sine signalatanh(t) an inverse hyperbolic tangent signalsign(t) a signum signal

Page 165: Basic Engineering Mathematics with Matlab

Note that the function atan2(b,a) requires two variables and returns a value in [- , ] and atan(t) just requires one variable returns a value in [- /2, /2].

atan(- 0.5) ans = - 0.4636

atan2(- 1,2) ans = - 0.4636

Page 166: Basic Engineering Mathematics with Matlab

atan2(1,- 2) ans = 2.6779

atan(0.5) ans = 0.4636

atan2(1,2) ans = 0.4636

atan2(- 1, - 2) ans = - 2.6779

Page 167: Basic Engineering Mathematics with Matlab

7.MATLAB provides the following special operations to for a complex valued signal.

Notation Functionabs(x) the absolute value of xreal(x) the real value of ximag(x) the imaginary part of xconj(x) the conjugate value of xangle(x) the phase angle of x

Page 168: Basic Engineering Mathematics with Matlab

8.MATLAB provides the following special operations to round a real number.

ceil(x) round x toward plud infinityfix(x) round x toward toeard 0floor(x) round x toward minus infinityround(x) round x toward nearest integer

Page 169: Basic Engineering Mathematics with Matlab

9.If a complex can be computed in MATLAB. For example,

a = sqrt( - 1) a = 0 + 1.0000i exp(a) ans = 0.5403 + 0.8415i

ae

10.The instruction save test store all variables in the file called test.mat. The instruction load test retrieves all variable from test.mat

Page 170: Basic Engineering Mathematics with Matlab

x = 1 y = 2 z = 3 % Save all variable in test.mat save test % Clear the workspace clear % Check all variables are retrieved or not ? load test x y z

Page 171: Basic Engineering Mathematics with Matlab

% Save x and y in test.mat save test x y % Clear the workspace clear % Check all variables are retrieved or not ? load test x y

Page 172: Basic Engineering Mathematics with Matlab

11.A sound file can be stored in the mat-file. Usually, it has two variables Fs and y, where Fs is the sampling rate and the variable y contains the sound signal. To load the sound file sound.mat and plot and play the sound in the following program can be used:

load sound % The duration of the sound in second t = (1:length(y))/Fs; % Plot the sound Plot(t,y)

Page 173: Basic Engineering Mathematics with Matlab

% Play the sound sound(y,Fs)

In the Unix system there are several mat-files in the directory called /usr/local/matlab4.2c/to These sound files can be retrieved and played.

12.The contents of the current figure can be saved as a file with the following instruction: (a) print -dps filename (b) print -dpsc filename (c) print -deps filename

Page 174: Basic Engineering Mathematics with Matlab

(d) print -depsc filename to save a black and white postscript file, a color postscript file, a block and white encapsulated postscript file and a color encapsulated postscript file.

13.The instruction ezplot(f) plots the function f, where f is a symbolic expression with the variable t and t [ - 2, 2]. The instruction ezplot(f,[t1,t2]) plots the function f(t), where t [t1,t2]. The instruction ezplot(f, [t1,t2],fig) plots the function f(t), where t [t1,t2], with the figure number fig.

Page 175: Basic Engineering Mathematics with Matlab

f = ‘x^3’ ezplot(f); ezplot(f,[0,1000])

14.The absolute value of x can be computed as y = ‘(x^2)^(1/2)’ ezplot(y)

Page 176: Basic Engineering Mathematics with Matlab

15. The function tri(t), rec(t), u(t), f(t)= |t| can not be defined symbolically. Therefore, it is difficult to use the instruction ezplot to plot these function. In the following program listing there are three main programs called unit.m, rec1.m and tri1.m and there are two functions called rec.m and tri,m.Figure 1.7, 1.8 and 1.9 are plotted by the commands unit, rec1 and tri1, respectively.

Page 177: Basic Engineering Mathematics with Matlab

Problems and Projects

Page 178: Basic Engineering Mathematics with Matlab

1.What is the frequency of sin(t) in Hz ?

2.Compute the energy of sin(t) between t=0 and t= 2? Does the energy increase as increase ?

Page 179: Basic Engineering Mathematics with Matlab

).sin(110)()(

).sin(110)()(

).sin(110)()(

).sin(110)()(

).sin(110)()(

).sin(110)()(

).sin()()(

23

7

34

6

5

32

4

23

32

1

wttfg

wttff

wttfe

wttfd

wttfc

wttfb

wttfa3.Plot the following signals

Page 180: Basic Engineering Mathematics with Matlab

4.Given the following signals

ti

ti

t

t

ti

ti

t

t

tetf

tetf

tttf

tttf

etf

etf

etf

etf

etf

etf

ttf

ttf

)1(12

)1(11

10

9

8

7

)1(6

)1(5

4

3

2

1

)(

)(

sin)(

cos)(

)(

)(

)(

)(

)(

)(

sin)(

cos)(

2

2

Page 181: Basic Engineering Mathematics with Matlab

(a) Which signals are bounded ?(b) Which signals have zero magnitudes as t0(c) Which signals are integrable ?(d) Which signals are absolute integrable ?(e) Which signals are square integrable ?(f) Which signals are periodic ?(g) Use the instruction ezplot to plot these signals

Page 182: Basic Engineering Mathematics with Matlab

5.Given the following signals

)()(

)()sin()(

)()cos()(

3

2

1

tueetf

tuwtetf

tuwtetf

jwtat

at

at

(a) Prove that ?)()(4

221 22

22

waawadttf

?)()(4

22 22

2

waawdttf

?)()( 21*

33

adttftf

(b) Prove that

(c) Prove that

Page 183: Basic Engineering Mathematics with Matlab

6.Prove the following functions have the same properties as the impulse and they can be considered as the impulse function as a0.

)](exp[

21

21

1

1

1

1

1

22

2

)(

))/(exp()(

)/(sin)(

)/(sin)(

)/||exp()(

)()/exp()(

)/()(

)/()(

taa

a

a

a

a

a

a

a

h

atg

atcf

atce

atd

tuatc

atrecb

attria

Page 184: Basic Engineering Mathematics with Matlab

7.Plot the following signals f(t)=cos(200(t+t0)+ cos(300(t+t0)+cos(400(t+t0))+cos(500 (t+t0))+cos(700(t+t0)) at(a) t0=0.

(b) t0=0.01.(c) t0=0.1.(d) t0=1.(e) t0=10.

Page 185: Basic Engineering Mathematics with Matlab

8.Compute the convolution between h(t) = and f(t), where f(t) is given as below:

te

(a) f(t) = sin(t)(b) f(t) = t(c) f(t) = (d) f(t) = 1.

te

Page 186: Basic Engineering Mathematics with Matlab

9.Write a program to generate a periodic pulse p(t) with duty cycle 10% and the period 1/1000 second and plot the following signals

f1(t) = p(t)(cos t)f2(t) = p(t)(cos 10t)f3(t) = p(t)(cos 100t)f4(t) = p(t)(cos 1000t)f5(t) = p(t)(cos 10000t)

Page 187: Basic Engineering Mathematics with Matlab

10.Given the following rectangular function h0(t) = 1, - 1/2t 1/2. Prove the following equations: h1(t) = h0(t)*h0(t) h2(t) = h0(t)*h0(t) *h0(t) h3(t) = h0(t)*h0(t) *h0(t) *h0(t), where

.,0

;01,1

;10,1

)(1

otherwise

tift

tift

th

Page 188: Basic Engineering Mathematics with Matlab

.,0

;21,)2(6/1

;10,2/13/2

;01,2/13/2

;12,)2(6/1

)(

.,0

;2/32/1,

;2/12/1,

;2/12/3,

)(

3

23

23

3

3

2)2/3(

243

2)2/3(

2 2

2

otherwise

tift

tiftt

tiftt

tift

th

otherwise

tif

tift

tif

tht

t

Page 189: Basic Engineering Mathematics with Matlab

11.Plot

.,0

;10,1)(

otherwise

tt

and prove).12()2()( ttt

Also,plot

.,0

;1,1

;0,1

)12()2()(

21

21

otherwise

t

t

ttt

Page 190: Basic Engineering Mathematics with Matlab

12.Plot the hat function is defined as

.,0

;21,2

;10,

)(

otherwise

tt

tt

t

and prove

2/)22()12(2/)2()( tttt

Page 191: Basic Engineering Mathematics with Matlab

13.Plot the piecewise linear spline function

.,0

;1||0|,|1)(

otherwise

ttt

and prove

2/)12()2(2/)12()( tttt

Page 192: Basic Engineering Mathematics with Matlab

14.Plot the quadratic B-spline function

.,0

;21,)1(

;10,)(

;01,)1(

)(2

21

221

43

221

otherwise

tt

tt

tt

t

and prove

)22()12()2()12()( 41

43

43

21 ttttt

Page 193: Basic Engineering Mathematics with Matlab

15.A signal f(t) = 110sin60t has the amplitude 110 and the frequency 60 Hz.Compute its rms value and the energy between t = 0 and t = 1 for 1 second.


Recommended