basic engineering mathematics with matlab

Post on 19-Jan-2016

83 Views

Category:

Documents

13 Downloads

Preview:

Click to see full reader

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

TRANSCRIPT

Basic Engineering Mathematics with Matlab

Professor Long-Wen Chang

National Tsing Hua University

Hsinchu, Taiwan

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..

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

Why a learning tool is needed ?

• To learn efficiently and effectively

• To learn by doing simulations

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.

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.

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.

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.

Chapter 1One Dimensional Continuous

Time Signals

Outline

• What are signals ?

• What are analog signals ?

• What are physical signals ?

• Bounded signals with finite energy

• Linear convolution of two analog signals

Introduction

What are Signals ?

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

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.

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.

What are Multimedia signals?

• Audio

• Video

• Image

• Text

• Graphics

Figure 1.1 shows a sound wave

Figure 1.2 shows a mandrill image.

Figure 1.1: A sound wave

Adam.wave

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)

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);

Figure 1.2: A mandrill image

A 256 gray level image

A binary image

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.

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

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

Continuous time signals means analog signals.

What are analog signals ?

Analog Signals

• Sinusoidal signals

• DC signals

• Unit step signals

• rectangular signals

• triangular signals

• Exponential signals

• square signals

Analog signals (continued)

• Sgn(t)

• Cosh(t)

• Sinh(t)

• Sinc(t)

Analog Signals(Continued)

• Nonperiodic signals

• Periodic signals

• Time limited signals

• non-time limited signals

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)

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

How to characterize a sinusoidalsignals?

• Amplitude

• Frequency

• Phase shift

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

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

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

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.

What are the frequencies of thefollowing signals ?

• sin(2t)

• sin(20t)

• sin(20t)

• sin(200t)

• sin(2000t)

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.

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]);

)2( tCOS

Figure 1.3: (a)cos(2t)

(b) sin(2t)

(c) f(t)=1

Figure 1.4: (a)sin(2t)

(b) sin(10t)

(c) sin(20t)

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.

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

Figure 1.5: (a) A decreasing exponential signal

te

(b) An increasing exponential signal

te

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.

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

Figure 1.7: A unit step signal

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.

9V

switch

electricdevice

Figure 1.6: An electric system with a 9 volt battery

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)

Figure 1.8: A rectangular signal

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)

Figure 1.9: A triangular signal

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

t

ttc

)sin(

1)(sin (1.9)

, if t = 0;

, otherwise.

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..

MATLAB program

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

Figure 1.10: A sinc signal

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

1

1)sgn(t (1.10)

,if t 0;

,if t < 0;

Figure 1.11: A sgn(t) signal

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

2/)( tt ee

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

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

(b) A sinh(t) signal

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.

Periodic signals

• Period

• Frequency

• Duty cycle

• Root mean squared value

• DC value

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.

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

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)

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

T

dc dttfT

f0

)(1

(1.13)

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.

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

.,

;0,)(

0

0

TtifTa

Ttifatf (1.14)

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.

<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]);

Figure 1.13: (a) A periodic square signal

(b) A period sawtooth signal

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.

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.

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]);

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.

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).

Figure 1.14: (a) a = 0.5

(b) a = 1

(c) a = 2

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)

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

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)

/

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:

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

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

(b) L = 2

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

(b) a = 1

(c) a = 2

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

(b) w=10

Figure 1.19: Gaussian functions with (a)=1

(b) =2

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)

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

0

1

0fLfdtLtututf LLLL

(1.24)

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

0tLtutuLL

As shown in Figure 1.20 we can write

Figure 1.20: Illustraction of

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

Physical Signals

• Bounded

• finite energy

• How to compute the energy of a signal ?

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)

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

dttfE )(2

(1.26)

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)

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)

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)

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

ans =1/2*inf

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:>

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

1/2

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

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,

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

(1.36)

)1(4

2

)1(4

1

4

1)]()cos([

2

2

22

tute t

(1.37)

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

ans =

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

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

dttf )( (1.38)

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

1)( 21

21

dttrec (1.39)

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

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

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:

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

0

)()()(*)(

daatfaftftf

(1.42)

(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)

(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)

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

0

)()()(*)(

daatfaftftf

(1.45)

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

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

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

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

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

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;

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:

Definition 26 : A complex-valued analog signal

)()()( 21 tjftftf

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

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)

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)

Example 16 : The signal

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

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

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

(b) [-5,5]

Figure 1.24:

tje 2

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

(b) [-5,5]

Definition 28 : The signal

tae t cos and

tae t sin, >0 are called damped sinusoids.

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

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)

<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

MATLAB Programming

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,

>> 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 =

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,

>> 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

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

For example,

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

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

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

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

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

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

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

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

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

>> 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.

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

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

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

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

atan2(1,- 2) ans = 2.6779

atan(0.5) ans = 0.4636

atan2(1,2) ans = 0.4636

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

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

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

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

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

% 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

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)

% 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

(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.

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)

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.

Problems and Projects

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 ?

).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

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

(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

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

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

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.

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

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)

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

.,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

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

12.Plot the hat function is defined as

.,0

;21,2

;10,

)(

otherwise

tt

tt

t

and prove

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

13.Plot the piecewise linear spline function

.,0

;1||0|,|1)(

otherwise

ttt

and prove

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

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

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.

top related