10
Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada ece.uwaterloo.ca [email protected] © 2012 by Douglas Wilhelm Harder. Some rights

Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

Embed Size (px)

Citation preview

Page 1: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

Interesting Functions in Matlab

Douglas Wilhelm Harder, M.Math. LELDepartment of Electrical and Computer Engineering

University of Waterloo

Waterloo, Ontario, Canada

ece.uwaterloo.ca

[email protected]

© 2012 by Douglas Wilhelm Harder. Some rights reserved.

Page 2: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

2

Outline

You are already familiar with trigonometric and exponential functions

We will now look at:– square wave functions– saw-toothed wave functions– triangular pulses– the cardinal sine function

Interesting Functions in Matlab

Page 3: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

3

Square Wave Function

The square-wave function has a period of 2p and an be thought of as follows:

x = 0:0.0001:20;plot( x, square( x ) )ylim( [-1.2 1.2] )square( 0 ) ans = 1

square( pi ) ans = -1

sin sin 0

square 1 2

sin sin 0

n

x x

x x n

x x

Interesting Functions in Matlab

Page 4: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

4

Saw-toothed Wave Functions

The default saw-toothed has a period of 2p and an be thought of as follows:

x = 0:0.0001:20;plot( x, sawtooth( x ) )ylim( [-1.2 1.2] )sawtooth( 0 ) ans = -1sawtooth( pi ) ans = -1

sawtooth 2 12

x xx

Interesting Functions in Matlab

Page 5: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

5

Saw-toothed Wave Functions

A second argument indicates what proportion into the interval [0, 2p] the peak of the tooth appears– The defualt is identical to sawtooth( x, 1 )

x = 0:0.0001:20;plot( x, sawtooth( x, 0.5 ) )ylim( [-1.2 1.2] )

0.5

Interesting Functions in Matlab

Page 6: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

6

Saw-toothed Wave Functions

The last interesting case has the parameter as 0:

x = 0:0.0001:20;plot( x, sawtooth( x, 0 ) )ylim( [-1.2 1.2] )square( 0 ) ans = 1square( pi ) ans = -1

sawtooth ,0 1 22

x xx

Interesting Functions in Matlab

Page 7: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

7

The Cardinal Sine Function

The sinc function is not periodic and is defined as:

x = -10:0.0001:10;plot( x, sinc( x ) )ylim( [-1.2 1.2] )

1 0

sinc sin0

x

x tx

t

Interesting Functions in Matlab

Page 8: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

8

The Triangular Pulse Function

The triangular-pulse function is not periodic and is defined as:

x = -2:0.0001:2;plot( x, tripuls( x ) )ylim( [-1.2 1.2] )

0 1

1 1 0tripuls

1 0 1

0 1

x

x xx

x x

x

Interesting Functions in Matlab

Page 9: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

9

Summary

We have quickly covered some of the special functions in Matlab– square, sawtooth, tripuls and sinc

This will be used later in applications

Interesting Functions in Matlab

Page 10: Interesting Functions in Matlab Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

10

References

[1] Jack Little, Cleve Moler, and Steve Bangert, Matlab, Mathworks, 1984-2012.

Interesting Functions in Matlab