7/17/2019 Ch12 Fitting Curve
1/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechan
ge,
degrees/hour
Numerical Techniques
Chapter 12
0 1 2 3 4 5 6-10
0
10
20
30
40
50
60Fit of Water Flow
Water Height, ft
Flow
Rate,CFS
Data
Linear FitQuadratic Fit
Cubic Fit
7/17/2019 Ch12 Fitting Curve
2/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
Section 12.2
Curve Fitting
There is scatter in all collected
data
!e can estimate the equation thatrepresents the data "#
$e#e"alling% a graph
There &ill "e points that do not fallon the line &e estimate
7/17/2019 Ch12 Fitting Curve
3/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
This line is 'ust a $"est guess%
7/17/2019 Ch12 Fitting Curve
4/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
(east Squares
Finds the $"est fit% straight line
)inimi*es the amount each point
is a&a# from the line +ts possi"le none of the points &ill
fall on the line
(inear Regression
7/17/2019 Ch12 Fitting Curve
5/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
-ol#nomial Regression
(inear Regression finds a straight
line, &hich is a first order
pol#nomial +f the data doesnt represent a
straight line, a pol#nomial of
higher order ma# "e a "etter fit
7/17/2019 Ch12 Fitting Curve
6/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
+n )T(/ #ou do "oth linear
and pol#nomial regression the
same &a# 0 the onl# difference isthe order
7/17/2019 Ch12 Fitting Curve
7/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturecha
nge,
degrees/hour
pol#fit and pol#val
polyfitfinds the coefficients of a
pol#nomial representing the data
polyvaluses those coefficients tofind ne& values of #, that
correspond to the no&n values
of
7/17/2019 Ch12 Fitting Curve
8/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturecha
nge,
degrees/hour
Coefficients of the
first order
pol#nomial
descri"ing the "estfit line
2.9143* 14.2857y x= +
7/17/2019 Ch12 Fitting Curve
9/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturecha
nge,
degrees/hour
(inear Regression
3First 4rder5
6valuate ho& close a fit
#ouve achieved "# taing
the difference "et&een
the measured andcalculated points, and
adding them up
7/17/2019 Ch12 Fitting Curve
10/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturecha
nge,
degrees/hour
Second 4rder Fit
7/17/2019 Ch12 Fitting Curve
11/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturecha
nge,
degrees/hour
fifth order pol#nomial gives a perfect fit
to 7 points
7/17/2019 Ch12 Fitting Curve
12/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturecha
nge,
degrees/hour
+mprove #our graph "# adding more
points
7/17/2019 Ch12 Fitting Curve
13/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
Section 12.89sing the +nteractive Curve Fitting
Tools
)T(/ : includes ne& interactive
plotting tools.
The# allo& #ou to annotate #our plots,
&ithout using the command &indo&.
The# include
"asic curve fitting,
more complicated curve fitting statistical tools
7/17/2019 Ch12 Fitting Curve
14/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
9se the curve fitting tools;
Create a graph
)aing sure that the figure
&indo& is the active &indo&select
Tools
7/17/2019 Ch12 Fitting Curve
15/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
7/17/2019 Ch12 Fitting Curve
16/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
-1 0 1 2 3 4 5 6 7-20
0
20
40
60
80
100
120Some Data
Time, seconds
Tem
perature,degreesF
y = 21*x + 3.8
y = 1.1*x3- 9.3*x2+ 41*x - 3.1
data 1
linear
cubic
-lot generated using the /asic Fitting !indo&
7/17/2019 Ch12 Fitting Curve
17/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturechange,
degrees/hour
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-10
-5
0
5
10
residuals
-1 0 1 2 3 4 5 6 7-20
0
20
40
60
80
100
120Some Data
Time,seconds
Temperat
ure,degreesF
y = 21*x + 3.8
y = 1.1*x3- 9.3*x2+ 41*x - 3.1
Residuals are the difference "et&een the actual and calculated data
points
7/17/2019 Ch12 Fitting Curve
18/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturech
ange,
degrees/hour
/asic Fitting !indo&
7/17/2019 Ch12 Fitting Curve
19/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturech
ange,
degrees/hour
>ata Statistics !indo&
?ou can also access the
data statistics &indo&
from the figure menu "ar.
Select
Tools->Data Statistics
from the figure &indo&.
This &indo& allo&s #ou
to calculate statisticalfunctions interactivel#,
such as mean and
standard deviation,
"ased on the data in the
figure, and allo&s #ou to
save the results to the&orspace.
7/17/2019 Ch12 Fitting Curve
20/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturech
ange,
degrees/hour
Curve Fitting Tool"o
n optional tool"o that allo&s
more sophisticated curve fitting
+t must "e installed on #ourcomputer
To open t#pe
cftool
7/17/2019 Ch12 Fitting Curve
21/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturech
ange,
degrees/hour
Choose the data #ou &ant to plot and anal#*e in the
Curve Fitting and >ata !indo&s
7/17/2019 Ch12 Fitting Curve
22/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturech
ange,
degrees/hour
Curve Fitting !indo&s
7/17/2019 Ch12 Fitting Curve
23/23
MATLAB for Engineers 2E,by Holly Moore. 2009 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 retrievalsystem, or transmission in any form or by any means, electronic, 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
Rateoftemperaturech
ange,
degrees/hour
1800 1820 1840 1860 1880 1900 1920 1940 1960 1980
0
50
100
150
200
250
Census Year
Po
pulation,inmillions
US Population Data
pop vs. cdate
fit 1fit 2
This plot of 9SCensus >ata &as created using the
cftool interactive modeling capa"ilit#