Professional Documents
Culture Documents
-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
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
500
matrices
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.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
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
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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
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
-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.
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
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
-2
-1.5
-1
-0.5
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
-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
-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
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
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
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
-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
-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
-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
-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
-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
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
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
400
500
Notice that we created a 1 by 107
100 200 300 400 500
-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
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
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
-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
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
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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
300
400
• When you divide by 0, the
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.
Check the limits on your
-5
Rate of Change
-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
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
-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
-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
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.