You are on page 1of 60

Built-in MATLAB

-5
Rate of Change

Functions
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1
Chapter 3
-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

Test Scores Distribution of Test Scores


100 120

100
80
Average = 50
Average = 50 80

# of students
60

Score
60
40
40

100
20
20

0 0
200 0 200 400 600 800 1000 0 20 40 60 80 100
Student Number Score

300
100 120

400 100
80

80 Average = 50

# of students
Average = 50
500 60

Score
100 200 300 400 500
60
40
40

20
20

0 0
0 200 400 600 800 1000 0 20 40 60 80 100
Student Number Score

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change Objectives
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1
After studying this chapter you should be able
to:
-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• Use a variety of common mathematical functions


• Understand and use trigonometric functions in
MATLAB
100
• Compute and use statistical and data analysis
200
functions
300
• Generate uniform and Gaussian random-number
400

500
matrices
100 200 300 400 500

• Understand the computational limits of MATLAB


• Recognize and be able to use the special values and
functions built into MATLAB

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change
3.1 Using Built-in Functions
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
MATLAB uses function names consistent
time, hour

with most major programming languages

For example
100 • sqrt
200

300

400
• sin
500
100 200 300 400 500
• cos
• log

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Function Input can be either
scalars or matrices
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Function Input can be either
scalars or matrices
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Using Predefined
Functions
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• Functions consist of
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• Name
• Input argument(s)
100
• Output In MATLAB
200

sqrt (x)= result


300

400

500
100 200 300 400 500
sqrt(4)
ans = 2

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Some functions require
multiple inputs
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• Remainder function returns the


-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

remainder in a division problem


• For example the remainder of
100

200
10/3, is 1
300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Some functions return
multiple results
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• size function determines the


-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

number of rows and columns

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
You can assign names to
the output
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

The variable names are


arbitrary – choose something
100
that makes sense in the
200 context of your problem
300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change Nesting Functions
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change
3.2 Using the Help Feature
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

• There are functions for almost


-2.5

-2

-1.5

-1

-0.5

anything you want to do


0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• Use the help feature to find out


what they are and how to use
100

200
them
300

400
• From the command window
500
100 200 300 400 500
• From the help selection on the
menu bar

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change

From the Command Window


Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500
From the Help Menu

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
The windowed help function
-5
Rate of Change
can also be accessed using
Rate of temperature change, degrees/hour

-4.5

the doc command


-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
3.3 Elementary Math
Functions
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
3.3.1 Common Computations
As• inabs(x)
most computer languages,
absolutelog(x)
value is
the syntax for the natural log – there is no
ln•function
sign(x) plus or minus
defined in MATLAB
• exp(x) ex
100

200

300

400

500
100 200 300 400 500
• log(x) natural log
• log10(x) log base 10

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change 3.3.2 Rounding Functions
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5


-1

-0.5

0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
round(x)
• fix(x)
• floor(x)

100

200 ceil(x)
300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change
3.3.3 Discrete Mathematics
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2


-1.5

factor(x)
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• gcd(x,y) greatest common denominator


• lcm(x) lowest common multiple
• rats(x) represent x as a fraction
100

200
• factorial(x)
300

400

500
• nchoosek(n,k)

100 200 300 400 500

primes(x)
• isprime(x)

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change
3.4 Trigonometric Functions
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2


-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
sin(x) sine
• cos(x) cosine
• tan(x) tangent
• asin(x) inverse sine
100
• sinh(x) hyperbolic sine

200

300
asinh(x) inverse hyperbolic sine

400

500
100 200 300 400 500
sind(x) sine with degree input
• asind(x) inverse sin with degree
output

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change
3.5 Data Analysis Functions
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• • std(x)
-1

-0.5

0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
max(x)
• min(x) • var(x)
• mean(x)
100 • median(x)

200

300
sum(x)
400

500
100 200 300 400 500
• prod(x)
• sort(x)
• sortrows(x)
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5
3.5.1 Max and Min
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

When the max function is used with a


vector (either a row or a column), it
100 returns the maximum value in the
200
vector
300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

When x is a matrix,
the max is found for
each column
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
max value

index number where


the max value
occurs
100

200

300

400

500
100 200 300 400 500 The max function can also be used to
determine where the maximum occurs

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200
Vector of maximums
300

400

500
100 200 300 400 500

Vector of row numbers


MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300
3.5.4 Sorting Values
400

500
100 200 300 400 500

It’s easy to sort data in MATLAB, using the


sort function

The default is to sort in ascending order


MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400
To sort in descending order, just add the word
500
100 200 300 400 500
‘descend’ in the second input field

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB is column dominant, so


when sort is used with a 2-D matrix,
each column is sorted in ascending
order MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
The sortrows function allows
100 200 300 400 500

you to sort entire rows, based


on the value in a specified
column.
The default sorting column is
#1
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

In this example the matrix is sorted


in ascending order, based on the
second column
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

Notice that this is a different


strategy than that used by the
sort function!
100

200

300

400

500
100 200 300 400 500

To sort based on
descending order, place a
negative sign in front of the
column number
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change
3.5.5 Determining Matrix Size
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• size(x)
-1

-0.5

0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
number of rows and
columns
• length(x) biggest dimension
100

200

• numel(x)
300

400

500
total number of
elements
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
3.5.6 Variance and Standard
-5
Rate of Change

Deviation
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5


-2

-1.5

• std(x)
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• var(x) 2

 (x − )
100
2
200

300
k
 = 2 k =1
400

N −1
500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change Standard Deviation
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change 3.6 Random Numbers
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• rand(x)
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• Returns an x by x matrix of random


numbers between 0 and 1
100
• rand(n,m)
200

300

400
• Returns an n by m matrix of random
500
100 200 300 400 500 numbers
• These random numbers are
evenly distributed
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

If you create a very large matrix of


random numbers using the rand
100
function, the average value will be
200 0.5
300

400

500
Notice that we created a 1 by 107
100 200 300 400 500

matrix, which required 2 inputs


(rand(1,10e6)). If we had entered a
single value (rand(10e6)) the result
would have been a 1x107 by 1x107
matrix.
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Gaussian Random
numbers
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• randn(n)
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• Also called a normal distribution


• Generates numbers with a mean
100

200
of 0 and a standard deviation of 1
300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5
First generate an
-1

-0.5

0
array of 10 million
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

gaussian random
numbers

Use MATLAB to
take the mean, and
100
notice that it is very
200 close to 0
300

400

500
Use MATLAB to
100 200 300 400 500

find the standard


deviation, and
notice that it is
very close to 1

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200
The hist function creates a
histogram of the input data
300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change
To generate random
Rate of temperature change, degrees/hour

numbers between other


-4.5

-4

-3.5

-3

-2.5

-2

bounds…
-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300
x = (b − a)  r + a
a and b are the upper and lower
400

500

bounds
100 200 300 400 500

r is the array of random numbers

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Test Scores Distribution of Test Scores
100 120
Rate of Change
-5
100
80
Rate of temperature change, degrees/hour

-4.5

-4 Average = 50
-3.5

Average = 50 80

# of students
-3

-2.5
60

Score
-2

-1.5
60
-1

-0.5
40
0
40
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

20
20

0 0
0 200 400 600 800 1000 0 20 40 60 80 100
Student Number Score

100 120

100
80
100

80 Average = 50

# of students
Average = 50
200 60
Score

300
60
40
400 40

500 20
100 200 300 400 500 20

0 0
0 200 400 600 800 1000 0 20 40 60 80 100
Student Number Score

Although the average is the same for each of these data sets,
they have a different standard deviation
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
More about Manipulating
Matrices
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• M(:)
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• Converts a two dimensional matrix


to a single column
100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change 3.7 Complex Numbers
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• complex(x,y)
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• real(A) used if A is a
complex number
• imag(A)
100

200

300
• isreal(A)
400

500
• conj(A) imaginary
100 200 300 400 500

• abs(A) real
• angle(A)
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change 3.8 Computational Limits
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• MATLAB’s computational range


-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

on most computers is:


• 10-308
100
• 10308
200

300

400
• When you divide by 0, the
500
100 200 300 400 500

computer returns Inf

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Check the limits on your
-5
Rate of Change

computer with these commands


Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5


-1

-0.5

0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
realmax
• realmin
• intmax

100

200 intmin
300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
When using very large or very small
-5
Rate of Change
numbers the result may depend on
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2
the order of operation
-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
3.9 Special Values and
Miscellaneous Functions
Rate of Change
-5
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2


-1.5

pi
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• i,j
Hint: The function i is the
• Inf
most common of these
• NaN
100

200
• clock
functions to be
300

400
• date
unintentionally renamed
500
100 200 300 400 500

• eps by MATLAB users.


• ans

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change Summary
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

• MATLAB contains a wide array of


-1.5

-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

predefined functions
• Elementary Math Functions
100
• Trigonometric Functions
200

300
• Data Analysis Functions
400

500
• Random Numbers

100 200 300 400 500

Complex Numbers

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change Summary
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• The colon operator allows you to


-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

manipulate matrices

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.
-5
Rate of Change Summary
Rate of temperature change, degrees/hour

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

• Computational Limits
-1

-0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour

• Special Values and Functions

100

200

300

400

500
100 200 300 400 500

MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is protected by Copyright and written permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s),
write to: Rights and Permissions Department, Pearson Education, Inc., Upper Saddle River, NJ 07458.

You might also like