Anda di halaman 1dari 60

MATLAB in Signal & Systems

By
Davood Shaghaghi
davood.shaghaghi@gmail.com

Step :

heaviside(t)

0.8

0.6

0.4

0.2

-1

-0.5

0.5

1
t

1.5

2.5

ramp :

t heaviside(t)

0
0

4
t

Sinusoidal signals:

exp(2 i conj(t)) + 1/exp(2 i t)

i exp(2 i conj(t)) - i/exp(2 i t)

1.5

1.5

0.5

0.5

-0.5

-0.5

-1

-1

-1.5

-1.5

-2

-2
-6

-4

-2

0
t

-6

-4

-2

0
t

An example,ploting square wave :

heaviside(t + 1) - heaviside(t - 1)

0.8

0.6

0.4

0.2

-2

-1.5

-1

-0.5

0
t

0.5

1.5

Time shifting :

Right shift :

heaviside(t) - heaviside(t - 2)

0.8

0.6

0.4

0.2

-2

-1.5

-1

-0.5

0.5
t

1.5

2.5

Left shift :

heaviside(t + 2) - heaviside(t)

0.8

0.6

0.4

0.2

-3

-2.5

-2

-1.5

-1

-0.5
t

0.5

1.5

For any linear combination:


>> xk=subs(x,a*t+b)

Decompose to even & odd signals :


heaviside(t - 1) - heaviside(t - 2) -...+ heaviside(t)

1.5

0.5

-1

-0.5

0.5

1.5
t

2.5

x=u(t)-ut-3)+u(t-1)-u(t-2);

3.5

xe=1/2(x(t)+x(-t))

heaviside(-t)/2 +...+ heaviside(t)/2

heaviside(t - 1)/2 -...+ heaviside(t)/2

1
0.9
0.8

0.5
0.7
0.6

0.5
0.4

-0.5

0.3
0.2

-1

0.1
0
-3

-2

-1

0
t

-3

-2

-1

0
t

heaviside(t - 1) - heaviside(t - 2) -...+ heaviside(t)


2
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0

0.5

1.5
t

2.5

Plot discrete signals:


step:

1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-3

-2

-1

Discrete Sinusoidal signals:

X1[n]

1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

20

40

60

80

100

120

X2[n]

0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

20

40

60

80

100

120

Exercise :

Dirac properties in general form:

Waveform Generation :
(aperiodic) square wave :
t
t
rect ( ) ( ) u(t T ) u(t T )
T
T
1

-T

In Matlab :
The rectpuls function generates a sampled aperiodic, unity-height
rectangular pulse centered about t = 0 and with a default width of 1.

0.8

0.6

0.4

0.2

0
-4

-3

-2

-1

t
t
rect ( ) ( ) u(t 2) u(t 2)
4
4

(aperiodic) Sawtooth wave :


t
1 T

t
t

( ) 1
T T
0

; T t 0

; 0t T
; |t|T

-T

In Matlab :
The tripuls function generates a sampled aperiodic, unity-height
triangular pulse centered about t = 0 and with a default width of 1.

0.8

0.6

0.4

0.2

0
-4

-3

-2

-1

( t )
3

(periodic) square wave :


The square function generates a square wave with a period of 2*pi. An
optional parameter specifies duty cycle, the percent of the period for
which the signal is positive.

Square Periodic Wave


1
0.8
0.6

Amplitude

0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-5

-4

-3

-2

-1

0
1
Time (sec)

(periodic) sawtooth wave :


The sawtooth function generates a sawtooth wave with peaks at 1 and a
period of 2*pi. An optional width parameter specifies a fractional
multiple of 2*pi at which the signal's maximum occurs.

Sawtooth Periodic Wave

Amplitude

1
0.5
0
-0.5
-1
0

0.02

0.04

0.06

0.02

0.04

0.06

0.08
0.1
0.12 0.14
Time (sec)
Sawtooth Periodic Wave

0.16

0.18

0.2

0.16

0.18

0.2

Amplitude

1
0.5
0
-0.5
-1
0.08
0.1
0.12
Time (sec)

0.14

Example:

discrete convolution

f1[n]
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-10

-8

-6

-4

-2

10

g1
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-10

-8

-6

-4

-2

10

correction of signals f1 and g1 :

f1
1

0.5

0
-10

-8

-6

-4

-2

10

10

g1
1

0.5

0
-10

-8

-6

-4

-2

h[n]
4

3.5

2.5

1.5

0.5

0
-20

-15

-10

-5

10

15

20

Discrete-Time Signal Functions :


Magnitude response (freqz)
Phase response (phasez)
Group delay (grpdelay)

Phase delay (phasedelay)


Impulse response (impz)
Step response (stepz)
Pole-zero plots (zplane)
Zero-phase response (zerophase)

>> freqz
[h,w] = freqz(hd) returns the frequency response vector h and the corresponding

frequency vector w for the discrete-time filter hd. When hd is a vector of


discrete-time filters, freqz returns the matrix h. Each column of h corresponds
to one filter in the vector hd.
Freqz(hd) uses FVTool to plot the magnitude and unwrapped phase of the

frequency response of the adaptive filter hd .If hd is a vector of filters ,


freqz plots the magnitude response and phase for each filter in the vector .

>> impz
[h,t] = impz(hd) computes the instantaneous impulse response of the discrete

-time filter hd choosing the number of samples for you, and returns the response
in column vector h and a vector of times or sample intervals in t where
(t = [0 1 2...]'). impz returns a matrix h if hd is a vector. Each column of the matrix
corresponds to one filter in the vector. When hd is a vector of discrete-time filters,
impz returns the matrix h. Each column of h corresponds to one filter in the vector
hd.
impz(hd) uses FVTool to plot the impulse response of the discrete-time filter hd.

If hd is a vector of filters, impz plots the response and for each filter in the vector.

>> stepz
[h,t] = stepz(ha) returns the step response h of the multirate filter ha. The length

of column vector h is the length of the impulse response of ha. Returned vector t
contains the time samples at which stepz evaluated the step response. stepz
returns h as a matrix when ha is a vector of filters.
Each column of the matrix corresponds to one filter in the vector.
stepz(ha) displays the filter step response in the Filter Visualization Tool

(FVTool).

>> fvtool
FVTool(f) displays the signal step response , impulse response and

in the Filter Visualization Tool.


f is your signal in time domain.

Solution of problems (related to laplace transform)

1.
3

2.
3

Bode Diagram

Magnitude (dB)

-50

-100

-150

-200
-360

Phase (deg)

-360
-360
-360
-360
-360
-1

10

10

10
Frequency (rad/sec)

10

3.
3

24

Impulse Response

x 10

-1

Amplitude

-2

-3

-4

-5

-6

-7
0

10

15
Time (sec)

20

25

30

23

Step Response

x 10

Amplitude

-5

-10

-15

-20

10

15
Time (sec)

20

25

30

5.

Find the step and impulse response of below systems


described by block diagram : (use matlab simulink)

First we must simulate the block diagram.


Then : Right click on the signal wire, click on the Linearization point
select input point for input of transfer function and Output point
for output of transfer function.
You can see the results in the next page

1
s+1
Transfer Fcn4

Step
1

Manual Switch

Derivative

s+1

s+1

s+1

s+1

Transfer Fcn

Transfer Fcn1

Transfer Fcn2

Transfer Fcn3

du/dt
Step1

1
s+1
Transfer Fcn5

Scope

weblog:

Shaghaghi.persiangig.com
e-mail:

davood.shaghaghi@gmail.com

Good Luck

Anda mungkin juga menyukai