In: Advanced Math
Alternative-Fueled Vehicles The table shows the numbers (in thousands) of alternative-fueled
vehicles A in use in the United States from 1995 to 2011. (Source: U.S. Energy Information Administration)
Year |
Number of vehicles, A |
1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 |
246.9 265.0 280.2 295.0 322.3 394.7 425.5 471.1 534.0 565.5 592.1 634.6 695.8 775.7 826.3 938.6 1191.8 |
(a) Use a graphing utility to plot the data. Let t represent the year, with t = 5 corresponding to 1995. (b) A model for the data is
4615.36t − 8726.7
1 + 15.01t − 0.542t2, 5 ≤ t ≤ 21
where t = 5 corresponds to 1995. Use the model to estimate the numbers of alternative-fueled vehicles in 1996, 2006, and 2011. How do your answers compare to the original data?
(f ) Use the model to predict the numbers of alternative-fueled vehicles in 2016 and 2017
* Need help to understand F . Should I be using a particular formula
%%Matlab code for plotting
clear all
close all
%data for year wise number of vehicles
year=[1995:2011];
A=[246.9 265 280.2 295 322.3 394.7 425.5 471.1 534 565.5 592.1
634.6 695.8 775.7 826.3 938.6 1191.8];
tt=5:21;
%2nd order polynomial fit
P=polyfit(tt,A,2);
f1=@(t) P(1).*t.^2+P(2).*t+P(3);
fprintf('function for 2nd order fit= (%2.2f)*t^2+(%2.2f)*t+(%2.2f) \n',P(1),P(2),P(3))
%3rd order polynomial fit
P=polyfit(tt,A,3);
f2=@(t) P(1).*t.^3+P(2).*t.^2+P(3).*t+P(4);
fprintf('function for 3rd order fit= (%2.2f)*t^3+(%2.2f)*t^2+(%2.2f)*t+(%2.2f) \n',P(1),P(2),P(3),P(4))
%1st model data
A1=f1(tt);
%2nd model data
A2=f2(tt);
hold on
plot(tt,A,'r*','linewidth',2);
plot(tt,A1)
plot(tt,A2)
xlabel('year')
ylabel('number of vehicle')
title('vehicle number vs. year plot')
legend('Actual data','2nd order fit','3rd order
fit','location','best')
fprintf('\t the numbers of alternative-fueled vehicles in 2016 using 2nd order fit=%f\n',f1(26))
fprintf('\t the numbers of alternative-fueled vehicles in 2016 using 3rd order fit=%f\n',f2(26))
fprintf('\t the numbers of alternative-fueled vehicles in 2017 using 2nd order fit=%f\n',f1(27))
fprintf('\t the numbers of alternative-fueled vehicles in 2017 using 3rd order fit=%f\n',f2(27))
%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%