Chapter6 Prob32
Chapter6 Prob32
6.32 Use MATLAB’s built-in functions to determine the coefficients of the third-order polynomial,
H C = a 3 x 3 + a 2 x 2 + a 1 x + a 0 (where x is the number of years after 1981) that best fits the data in Problem
6.31. Use the polynomial to estimate the percent of computer ownership in 2008 and in 2013. In one fig-
ure, plot the polynomial and the data points.
Solution
The problem is solved in the following script file:
clear, clc,
Y=[1981 1984 1989 1993 1997 2000 2001 2003 2004 2010];
H=[0.5 8.2 15 22.9 36.6 51 56.3 61.8 65 76.7];
x=Y-1981;
p=polyfit(x,H,3)
% Estimated ownership in 2008
Hc2008=polyval(p,2008-1981)
% Plot
Tp=1981:0.5:2010;
Hcp=polyval(p,Tp-1981);
plot(Tp,Hcp,Y,H,'*')
xlabel('Year')
ylabel('Household with Computers (%)')
When the script is executed the following results are displayed in the Command Window, and the follow-
ing figure is displayed.
p =
-0.004821523271264 0.238024221835913 -0.275993574014962
3.084977758051978
Hc2008 =
74.250766429729410
>> 4
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
2
80
70
60
40
30
20
10
0
1980 1985 1990 1995 2000 2005 2010
Year
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.