Académique Documents
Professionnel Documents
Culture Documents
Rate of Change
Other Kinds of Arrays
Chapter 11
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
14
100
12
200
10
300
8
400
500
100 200 300 400 500
6
0 2000 4000 6000 8000 10000
Number of steps*1000
MATLAB for Engineers 4E, by Holly Moore. © 2014 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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
300
arrays
400
• Create multidimensional arrays, and access
data in those arrays
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Section 11.1
Data Types
Rate of Change
-5
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
300
supports a number of different
400
500
secondary data types (classes)
• The default is a double precision
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
MATLAB’s arrays can store
different types of data
Rate of Change
-5
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
Symbolic Objects -
Character Logical Numeric Symbolic Toolbox
100
Integer Floating Point
200
300
400
complex real
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
There are a variety of array
types to store the data
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
MATLAB Array Types
time, hour
Most of these
arrays can
100
200
Integer Floating Point
300
only hold
400
information of
500
100 200
one data type
300 400 500
multiple multiple single double
signed unsigned precision precision
integer types integer types
-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
• Consider the following analogy
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
There are lots of different places you
could store your wealth
Rate of Change
-5
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
They
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
correspond
to the
array types
100
200
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
There are lots of different kinds of
-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
They
correspond to
the data types
100
200
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Numeric Data Types
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
arrays
time, hour
400
you’ve entered a double
500
100 200 300 400 500
• MATLAB conforms to the IEEE
standards that specify the meaning of
the double data type
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 you define numeric
-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
200
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
There are 6 values in the C
-2
-1.5
-1
array – therefore it requires
-0.5
0
0 0.5 1 1.5 2 2.5
time, hour
3 3.5 4 4.5 5
6 x 8 = 48 bytes of memory
100
200
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Value limitations
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
• The smallest number you can
300
400
store in a double can be found
500
100 200 300 400 500
using the realmin function
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Single Precision floating
point numbers
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
double
• Each value requires
100
200
• 4 bytes = 32 bits
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
The grid symbol indicates a numeric
200 array – double, single or integer
300
400
500
100 200 300 400 500 It’s necessary to use the
single function to change
the value of 5 (which is a
double by default) into a
single
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Value limitations
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
400
500
100 200 300 400 500
• The smallest number you can store in a
double can be found using the
realmin(‘single’) function
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
• Engineers will rarely
Rate of Change
need to convert to
single precision
-5
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
numbers, because
-3
-2.5
-2
-1.5
• today’s computers
-1
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
have plenty of
storage space for
most applications,
• and will execute
100 most of the
200
problems we pose in
extremely short
300
400
500
100 200 300 400 500
amounts of time
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 would you use the short data
-5
Rate of Change
-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
500
100 200 300 400 500
• However, round off error becomes
more of a problem.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Consider the harmonic
series
Rate of Change
-5
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
100 n 1
1 / n Shorthand for the harmonic series
200
300
400
This series diverges -it just keeps getting
500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
For large numbers of steps the results
are different using double and single
Rate of Change
data types
-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
14
100
single
200
12
300
10
400
500
100 200 300 400 500
8
6
0 2000 4000 6000 8000 10000
Number of steps*1000
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Why?
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
300
• Since doubles can differentiate
400
500
between smaller numbers than singles
the summation is valid for more steps
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Each of these
types require a
-5
Rate of Change Integers different amount
of storage
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
-1
-0.5
200
16-bit signed int16 16-bit unsigned uint16
300
integer integer
400
500
32-bit signed int32 32-bit unsigned uint32
100 200 300 400 500
integer integer
64-bit signed int64 64-bit unsigned uint64
integer integer
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 determine the number of
possible values allowed in the
Rate of Change
-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
500
100 200 300 400 500
• intmax and intmin
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
When do we use integers
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
image information
• These arrays are often very large, but
there are a limited number of colors
100
used in many of these images to
create the picture.
200
300
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Complex numbers
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
• Default is double
-1
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
200
components must be stored
300
400
• Could also be stored as a single
500
100 200 300 400 500
or integer
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Character and String Data
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
information
• A character array is produced
100
200
from a string
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
200
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
200
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
array in MATLAB
• Each character requires 2 bytes of
100
200
storage
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
How are characters stored in
MATLAB?
Rate of Change
-5
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
200
super computers
300
400
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Comparison between base 2
and base 10
Rate of Change
-5
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
Base 2 ”binary”
-1.5
-1
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Base 10
”decimal”
time, hour
1 1
10 2
100
11 3
200
100 4
300
400 101 5
500
100 200 300 400 500
110 6
111 7
1000 8
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
200
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
MATLAB includes functions
to change data types
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
Use char to convert a
400
number to a character
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 shouldn’t mix data types
-5
Rate of Change
in calculations or in arrays
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
500
100 200 300 400 500
There is no character
equivalent to 3, so
MATLAB adds a space
to the array
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
If you try to perform
arithmetic with a
combination of
character and numeric
data, MATLAB converts
the character to its
100
decimal equivalent
200
300
400
500
100 200 300 400 500
Remember that a has a
decimal equivalent of
97
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Symbolic Data
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
separate chapter
• The symbolic toolbox uses
100
200
symbolic data to perform symbolic
300
400
algebraic calculations
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
100 200 300 400 500
-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
two values
• True
100
• False
200
300
400
• MATLAB uses
• 0 to represent false and
500
100 200 300 400 500
• 1 to represent true
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
300
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Sparse Arrays
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
400
matrices
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Sparse matrices require less space
than the corresponding numeric or
logical matrices
Rate of Change
-5
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
200
300
400
stores the non-zero values, and
remembers where they are
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
N is a 1000x1000 identity
Compare the size of N and P
matrix
100
200
300
P is the same matrix, stored
400
using the sparse strategy
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Section 11.2
Multidimensional Arrays
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
300
400
• Pages
500
100 200 300 400 500
• Additional dimensions are possible
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Multidimensional arrays are
grouped into pages
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
columns
100
200
300
rows pages
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
Page 1
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
Page 2
100
200
300
Page 3
400
500
100 200 300 400 500
dimensional array
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
300
400
separately. Read the first
500
100 200 300 400 500
definition statement as
“all the rows, all the
columns, in page 1”
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Section 11.3
Creating Character Arrays
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
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
300
400
500
100 200 300 400 500
-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
500
100 200 300 400 500
• The number 1 is different from the
character 1
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Let’s combine an array of
test scores and names
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
• 98 • Holly
• 84 • Steven
• 73 • Meagan
• •
100
200 88 David
• •
300
400
95 Michael
• 100 • Heidi
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
200
300
When we tried to store the
400
two different data types into
500
100 200 300 400 500
the same array, MATLAB
interpreted the numbers as
the ASCII equivalent of
characters
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 num2str
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
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
The num2str function converted
the array of scores into the
corresponding characters
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Creation of file names
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
400
be required my_data1.dat
my_data2.dat
my_data3.dat
Etc.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 For example….
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
some_data
• Create a number of new files, one
100
200
for each column from the input file
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Input and Output
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
Output files
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Data from input file
time, hour
Data in File1
Data in File2
1 2 3 1 Data in File3
2
4 5 6 4 3
100
5
200
7 8 9 7 6
8
300
400
500
100 200 300 400 500
10 11 12 10 9
11
12
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
200
Extract the
300
data
400
Create the file
names
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Section 11.4
Cell Arrays
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
• Each element in the array is also
300
400
an array
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 Indexing
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
300
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
200
arrays
300
400
• Instead of using content indexing
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
This is still a 1x1
300 structure array –
400
however it has three
500
100 200 300 400 500
fields
-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
We can add more content to the
500
100 200 300 400 500
structure, and expand its size, by
adding more matrices to the
fields we’ve defined.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 access the
information using…
Rate of Change
-5
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
• Matrix name
-1
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
• Field name
• Index numbers
100
200
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
Just calling the matrix name
300
returns a description of the
400 array
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
You can use the field name to access
200 just the data in certain fields. This
300
example returns the arrays in the first
400
field of each member of the structure
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
variable editor to
access the
content of a
100
structure array
• Double click the
200
300
400
500
structure array
name in the
100 200 300 400 500
workspace
window
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
300
400
500
100 200 300 400 500
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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
the array
• MATLAB supports a number of
different array types, each of which
100
400
500
• Cell and structure arrays can store
more than one data type in the same
100 200 300 400 500
array
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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-Data Type
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
types
• Numeric
• double
100
• single
200
300
• 8 different types of integers
• Character
400
500
100 200 300 400 500
• Symbolic
• Logical
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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 - Array Types
Rate of temperature change, degrees/hour
-4.5
-4
-3.5
-3
-2.5
-2
• Numeric
-1.5
-1
-0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, hour
• double
• single
• 8 different integer arrays
• Character
• Symbolic
100
200
300
400
• Logical
500
100 200 300 400 500 • Sparse
• Cell
• Structure
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.
Summary –
Multidimensional Arrays
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
page
300
400
• Each page must be entered
500
100 200 300 400 500
separately as a two-dimensional
array
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved.
This material is 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.