Top Banner
Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 R ate ofC hange tim e, hour Rate of tem perature change, degrees/hour Built-in Matlab Functions Chapter 3 0 200 400 600 800 1000 0 20 40 60 80 100 TestS cores S tudentN um ber Score 0 20 40 60 80 100 0 20 40 60 80 100 120 D istribution ofTestS cores S core # ofstudents 0 200 400 600 800 1000 0 20 40 60 80 100 S tudentN um ber Score 0 20 40 60 80 100 0 20 40 60 80 100 120 S core # ofstudents A verage = 50 A verage = 50 A verage = 50 A verage = 50
50

Matlab for Engineers Built-in Matlab Functions Chapter 3.

Jan 13, 2016

Download

Documents

Elmer Bryan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Built-in Matlab Functions

Chapter 3 0 200 400 600 800 10000

20

40

60

80

100Test Scores

Student Number

Sco

re

0 20 40 60 80 1000

20

40

60

80

100

120Distribution of Test Scores

Score

# of

stu

dent

s

0 200 400 600 800 10000

20

40

60

80

100

Student Number

Sco

re

0 20 40 60 80 1000

20

40

60

80

100

120

Score

# of

stu

dent

s

Average = 50

Average = 50

Average = 50

Average = 50

Page 2: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

In this chapter we’ll cover

• Using Built in Functions• Using the Help Feature• Elementary Math Functions• Trigonometric Functions• Data Analysis Functions• Random Number Functions• Complex Number Functions• Computational Limits• Special Values and Miscellaneous Functions

Page 3: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Matlab uses function names consistent

with most major programming languages

For example• sqrt• sin• cos• log

Page 4: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Function Input can be either scalars or matrices

Page 5: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Function Input can be either scalars or matrices

Page 6: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Using Predefined Functions

• Functions consist of• Name• Input argument(s)• Output

sqrt (x)= result

In MATLAB

sqrt(4)

ans = 2

Page 7: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Some functions require multiple inputs

• Remainder function returns the remainder in a division problem

• For example the remainder of 10/3, is 1

Page 8: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Some functions return multiple results

• size function determines the number of rows and columns

Page 9: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

You can assign names to the output

Page 10: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Nesting Functions

Page 11: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

There are functions for almost anything you want to do

• Use the help feature to find out what they are and how to use them• From the command window• From the help selection on the

menu bar

Page 12: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r From the Command Window

Page 13: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

From the Help Menu

Page 14: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 15: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Elementary Math Functions

• abs(x) absolute value

• sign(x) plus or minus

• exp(x) ex

• log(x) natural log

• log10(x) log base 10

Page 16: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Rounding Functions

• round(x)

• fix(x)

• floor(x)

• ceil(x)

Page 17: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 18: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 19: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Discrete Mathmatics

• factor(x)• gcd(x,y) greatest common denominator

• lcm(x) lowest common multiple

• rats(x) represent x as a fraction

• factorial(x)• primes(x)• isprime(x)

Page 20: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Trigonometric Functions

• sin(x) sine• cos(x) cosine• tan(x) tangent• asin(x) inverse sine• sinh(x) hyperbolic sine• asinh(x) inverse hyperbolic sine• sind(x) sine with degree input• asind(x) inverse sin with degree

output

Page 21: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Data Analysis

• max(x)

• min(x)

• mean(x)

• median(x)

• sum(x)

• prod(x)

• sort(x)

Page 22: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

When x is a matrix, the max is found for each column

Page 23: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

max value

element number where the max value occurs

Page 24: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Vector of row numbers

Vector of maximums

Page 25: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Determining Matrix Size

• size(x) number of rows and columns

• length(x) biggest dimension

Page 26: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 27: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Variance and Standard Deviation

• std(x)• var(x)

11

2

2

N

xN

kk

2

Page 28: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Standard Deviation

Page 29: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Random Numbers

• rand(x)• Returns an x by x matrix of random

numbers between 0 and 1

• rand(n,m)• Returns an n by m matrix of random

numbers

• These random numbers are evenly distributed

Page 30: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 31: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 32: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 33: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Gaussian Random numbers

• randn(n)

• Also called a normal distribution

• Generates numbers with a mean of 0 and a standard deviation of 1

Page 34: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 35: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 36: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 37: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

To generate random numbers between other

bounds…

arabx a and b are the upper and lower bounds

r is the array of random numbers

Page 38: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

0 200 400 600 800 10000

20

40

60

80

100Test Scores

Student Number

Sco

re

0 20 40 60 80 1000

20

40

60

80

100

120Distribution of Test Scores

Score

# of

stu

dent

s

0 200 400 600 800 10000

20

40

60

80

100

Student Number

Sco

re

0 20 40 60 80 1000

20

40

60

80

100

120

Score

# of

stu

dent

s

Average = 50

Average = 50

Average = 50

Average = 50

Page 39: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

More about Manipulating Matrices

• M(:)• Converts a two dimensional matrix

to a single column

Page 40: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 41: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 42: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Complex Numbers

• complex(x,y)• real(A) used if A is a

complex number

• imag(A)• isreal(A)• conj(A)• abs(A)• angle(A)

real

imaginary

Page 43: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Computational Limits

• Matlab’s computational range on most computers is:• 10-308

• 10308

• When you divide by 0, the computer returns Inf

Page 44: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Check the limits on your computer with these commands

• realmax

• realmin

• intmax

• intmin

Page 45: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Page 46: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

When using very large or very small numbers the result may depend on

the order of operation

Page 47: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Special Values and Functions

• pi• i,j• Inf• NaN• clock• date• eps• ans

Hint: The function i is the most common of these functions to be unintentionally renamed by Matlab users.

Page 48: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Summary

• MATLAB contains a wide array of predefined functions• Elementary Math Functions• Trigonometric Functions• Data Analysis Functions• Random Numbers• Complex Numbers

Page 49: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Summary

• The colon operator allows you to manipulate matrices

Page 50: Matlab for Engineers Built-in Matlab Functions Chapter 3.

Matlab for Engineers

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

Summary

• Computational Limits

• Special Values and Functions