86
MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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. 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 R ate ofC hange tim e, hour Rate of tem perature change, degrees/hour Plotting Chapter 5 1 2 3 4 5 0 2 4 6 8 A bargraph ofvectorx 1 2 0 2 4 6 8 A bargraph ofm atrix y 1 2 3 4 5 1 2 0 5 10 A three dim ensional bargraph 5% 10% 25% 20% 40% A pie chartofx

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

Embed Size (px)

Citation preview

Page 1: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r Plotting

Chapter 51 2 3 4 5

0

2

4

6

8A bargraph of vector x

1 20

2

4

6

8A bargraph of matrix y

12

34

51

2

0

5

10

A three dimensional bargraph5%

10%

25%

20%

40%

A pie chart of x

Page 2: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Video of the Week

• https://www.youtube.com/watch?v=i7YIAWsyB1I

• “Once you become honors students, you stop having sex with animals.”

• Dr. Goss

Page 3: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

In this chapter we’ll cover

• Creating and labeling two dimensional plots

• Adjusting the appearance of your plots

• Creating multiple figures• Using subplots• Creating three dimensional plots• Using the interactive plotting tools

Page 4: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 5.1Two Dimensional Plots

• The xy plot is the most commonly used plot by engineers

• The independent variable is usually called x

• The dependent variable is usually called y

Page 5: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 this xy data

time, sec Distance, Ft

0 0

2 0.33

4 4.13

6 6.29

8 6.85

10 11.19

12 13.19

14 13.96

16 16.33

18 18.17

Time is the independent variable and distance is the dependent variable

Page 6: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Define x and y and call the plot function

You can use any variable name that is convenient for the dependent and independent variables

Page 7: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 8: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 always add …

• Title

• X axis label, complete with units

• Y axis label, complete with units

• Often it is useful to add a grid

Page 9: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 10: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Creating multiple plots

• MATLAB overwrites the figure window every time you request a new plot

• To open a new figure window use the figure function – for example figure(2)

Page 11: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Plots with multiple lines

• hold on • Freezes the current plot, so that an

additional plot can be overlaid

• When you use this approach the additional line is drawn in blue – the default drawing color

Page 12: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

The first plot is drawn in blue

Page 13: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

The hold on command freezes the plot

The second line is also drawn in blue, on top of the original plot

To unfreeze the plot use the hold off command

Page 14: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 also create multiple lines on a single graph with one

command

• Using this approach each line defaults to a different color

Page 15: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 set of ordered pairs will produce a new line

Page 16: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Variations

• If you use the plot command with a single matrix, MATLAB plots the values versus the index number

• Usually this type of data is plotted on a bar graph

• When plotted on an xy grid, it is often called a line graph

Page 17: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 18: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

If you want to create multiple plots, all with the same x value you can…

• Use alternating sets of ordered pairs• plot(x,y1,x,y2,x,y3,x,y4)

• Or group the y values into a matrix• z=[y1,y2,y3,y4]• plot(x,z)

Page 19: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Alternating sets of ordered pairs

Matrix of Y values

Page 20: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

The peaks(100) function creates a 100x100 array of values. Since this is a plot of a single variable, we get 100 different line plots

Page 21: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Line, Color and Mark Style

• You can change the appearance of your plots by selecting user defined • line styles• color• mark styles

• Try using help plot

for a list of available styles

Page 22: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Available choicesTable 5. 2 Line, Mark and Color Options

Line Type Indicator Point Type Indicator Color Indicator

solid - point . blue b

dotted : circle o green g

dash-dot -. x-mark x red r

dashed -- plus + cyan c

star * magenta m

square s yellow y

diamond d black k

triangle down v

triangle up ^

triangle left <

triangle right >

pentagram p

hexagram h

Page 23: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Specify your choices in a string

• For example• plot(x,y,':ok')

• strings are identified with a tick mark• if you don’t specify style, a default is

used• line style – none• mark style – none• color - blue

Page 24: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

plot(x,y,':ok')

• In this command• the : means use a dotted line• the o means use a circle to mark

each point• the letter k indicates that the graph

should be drawn in black• (b indicates blue)

Page 25: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

dotted line

circles

black

Page 26: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

specify the drawing parameters for each line after the ordered pairs that define the line

Page 27: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Axis scaling

• MATLAB automatically scales each plot to completely fill the graph

• If you want to specify a different axis – use the axis commandaxis([xmin,xmax,ymin,ymax])

• Lets change the axes on the graph we just looked at

Page 28: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Use the axis function to override the automatic scaling

Page 29: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Annotating Your Plots

• You can also add• legends• textbox

• Of course you should always add • title• axis labels

Page 30: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 31: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Improving your labels

You can use Greek letters in your labels by putting a backslash (\) before the name of the letter. For example:title(‘\alpha \beta \gamma’)

creates the plot title α β γ

To create a superscript use curly brackets title(‘x^{2}’)gives x2

Page 32: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Tex Markup Language

• These label improvements use the Tex Markup Language

• Use the Help feature to find out more!!

Page 33: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 5.2Subplots

• The subplot command allows you to subdivide the graphing window into a grid of m rows and n columns

• subplot(m,n,p)

rows columns location

Page 34: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

subplot(2,2,1)

2 rows

2 columns

1 2

3 4

-20

2-2

02

-5

0

5

x

Peaks

y

Page 35: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

2 rows and 1 column

Page 36: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 5.3Other Types of 2-D Plots

• Polar Plots• Logarithmic Plots• Bar Graphs• Pie Charts• Histograms• X-Y graphs with 2 y axes• Function Plots• LEARNING BY DOING!

Page 37: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Polar Plots

• Some functions are easier to specify using polar coordinates than by using rectangular coordinates

• For example the equation of a circle is• y=sin(x)in polar coordinates

Page 38: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 39: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Practice Exercise 5.3

• Try these exercises to create some interesting shapes

1

2

3

4

5

30

210

60

240

90

270

120

300

150

330

180 0

1

2

3

4

5

30

210

60

240

90

270

120

300

150

330

180 0

2

4

6

8

10

30

210

60

240

90

270

120

300

150

330

180 0

1

2

3

4

5

30

210

60

240

90

270

120

300

150

330

180 0

0.2

0.4

0.6

0.8

1

30

210

60

240

90

270

120

300

150

330

180 0

Page 40: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Logarithmic Plots

• A logarithmic scale (base 10) is convenient when • a variable ranges over many orders

of magnitude, because the wide range of values can be graphed, without compressing the smaller values.

• data varies exponentially.

Page 41: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

• plot – uses a linear scale on both axes

• semilogy – uses a log10 scale on the y axis

• semilogx – uses a log10 scale on the x axis

• loglog – use a log10 scale on both axes

Page 42: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

x-y plot – linear on both axes

semilogx – log scale on the x axis

semilogy – log scale on the y axis

loglog – log scale on both axes

Page 43: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 44: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Bar Graphs and Pie Charts

• MATLAB includes a whole family of bar graphs and pie charts• bar(x) – vertical bar graph• barh(x) – horizontal bar graph• bar3(x) – 3-D vertical bar graph• bar3h(x) – 3-D horizontal bar graph• pie(x) – pie chart• pie3(x) – 3-D pie chart

Page 45: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 46: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 47: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Histograms

• A histogram is a plot showing the distribution of a set of values

Page 48: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Defaults to 10 bins

Page 49: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

X-Y Graphs with Two Y Axes

• Sometimes it is useful to overlay two x-y plots onto the same figure. However, if the order of magnitude of the y values are quite different, it may be difficult to see how the data behave.

Page 50: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 example

Page 51: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Scaling Depends on the largest value plotted

• Its difficult to see how the blue line behaves, because the scale isn’t appropriate

Page 52: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

The plotyy function allows you to use two scales on a single graph

Page 53: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Function Plots

• Function plots allow you to use a function as input to a plot command, instead of a set of ordered pairs of x-y values

• fplot('sin(x)',[-2*pi,2*pi])

function input as a string

range of the independent variable – in this case x

Page 54: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 55: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 5.4Three Dimensional Plotting

• Line plots

• Surface plots

• Contour plots

Page 56: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Three Dimensional Line Plots

• These plots require a set of order triples ( x-y-z values) as input

The z-axis is labeled the same way the x and y axes are labeled

Page 57: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 uses a coordinate system consistent with the right hand rule

Page 58: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Just for fun

• try the comet3 function, which draws the graph in an animation sequence

• comet3(x,y,z) • If your animation draws too

slowly, add more data points• For 2-D line graphs use the comet function

Page 59: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Surface Plots

• Represent x-y-z data as a surface• mesh - meshplot• surf – surface plot

Page 60: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Both Mesh and Surf

• Can be used to good effect with a single two dimensional matrix

Page 61: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

The x and y coordinates are the matrix index numbers

Page 62: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Using mesh with 3 variables

• If we know the values of x and y that correspond to our z values, we can plot against those values instead of the index numbers

Page 63: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 64: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Surf plots

• surf plots are similar to mesh plots• they create a 3-D colored surface

instead of an open mesh• syntax is the same

Page 65: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 66: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Shading

• There are several shading options• shading interp• shading flat• faceted flat is the default

• You can also adjust the color scheme with the color map function

Page 67: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Colormaps

autumn bone hot

spring colorcube hsv

summer cool pink

winter copper prism

jet (default) flag white

Page 68: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Contour Plots

• Contour plots use the same input syntax as mesh and surf plots

• They create graphs that look like the familiar contour maps used by hikers

Page 69: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

To demonstrate these functions lets use a more interesting example

• A more complicated surface can be created by calculating the values of z, instead of just defining them

• We’ll need to use the meshgrid function to create 2-D input arrays – which will then be used to create a 2-D result

Page 70: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 71: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 72: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Pseudo Color Plots

• Similar to contour plots• Instead of lines, a 2-D shaded map

is created

• Uses the same syntax

• The following example uses the built-in MATLAB demonstration function peaks

Page 73: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 74: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Page 75: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 5.5Editing Plots from the Menu Bar

• In addition to controlling the way your plots look by using MATLAB commands, you can also edit a plot once you’ve created it using the menu bar

• Another demonstration function built into MATLAB is

sphere

Page 76: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Once you’ve created a plot you can adjust it using the menu bar

• In this picture the insert menu has been selected

• Notice you can use it to add labels, legends, a title and other annotations

Page 77: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Select

Edit-> Axis Properties from the menu tool bar

Select Inspector from the Property Editor

Change the Aspect Ratio

Explore the property editor to see some of the other ways you can adjust your plot interactively

Page 78: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

• If you adjust a figure interactively, you’ll lose your improvements when you rerun your program

Page 79: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Creating plots from the workspace

Page 80: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 will suggest plotting options and create the plot for you

Page 81: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Saving your plots

• Rerun your M-file to recreate a plot• Save the figure from the file menu

using the save as… option• You’ll be presented with several choices of

file format such as• jpeg• emg (enhanced metafile) etc

• Right-click on the figure and select copy – then paste it into another document

Page 82: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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

• The x-y plot is the most common used in engineering

• Graphs should always include titles and axis labels. Labels should include units.

• MATLAB includes extensive options for controlling the appearance of your plot

Page 83: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

• Multiple plots can be displayed in the same figure window

• Most common plot types are supported by MATLAB including• polar plots• bar graphs• pie charts• histograms

Page 84: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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 supports 3-D plotting• line plots• surface plots

• You can modify plots interactively from the menu bar

• You can create plots interactively from the workspace window

Page 85: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Saving Figures

• Figures created in MATLAB can be stored using a number of different file formats• File Save As• Edit Copy• print –option filename

Page 86: MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is

100 200 300 400 500

100

200

300

400

500

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5

0

Rate of Change

time, hour

Rat

e of

tem

pera

ture

cha

nge,

deg

rees

/hou

r

MATLAB for Engineers, by Holly Moore. ISBN 0-13-187244-3.© 2007 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.

Homework

• Problems 5.1, 5.3, 5.4, 5.5