Question: function c 1 x + c 2 , set up an overdetermined sys - tem V c = T . The coefficient matrix V can

function c1x+c2, set up an overdetermined sys-
tem Vc=T. The coefficient matrix V can be
generated in MATLAB by setting
V=[p, ones (10,1)]
or, alternatively, by setting
A=vander(p);,V=A(;,9:10)
Note For any vector x=(x1,x2,dots,xn+1)T,
the MATLAB command vander(x) generates
a full Vandermonde matrix of the form
([x1n,x1n-1,cdots,x1,1],[x2n,x2n-1,cdots,x2,1],[vdots,],[xn+1n,xn+1n-1,cdots,xn+1,1])
For a linear fit, only the last two columns of
the full Vandermonde matrix are used. More
information on the vander function can be
obtained by typing help vander. Once V
has been constructed, the least squares solu-
tion c of the system can be calculated using the
MATLAB "" operation.
(b) To see how well the linear function fits the data,
define a range of pressure values by setting
q=1:0.1:10;
The corresponding function values can be de-
termined by setting
z=polyval(c,q);
We can plot the function and the data points with
the command
(c) Let us now try to obtain a better fit by us-
ing a cubic polynomial approximation. Again
we can calculate the coefficients of the cubic
polynomial
c1x3+c2x2+c3x+c4
that gives the best least squares fit to the data
by finding the least squares solution of an over-
determined system Vc=T. The coefficient
matrix V is determined by taking the last four
columns of the matrix A= vander(p). To see
the results graphically, again set
z=polyral(c,q)
and plot the cubic function and data points, us-
ing the same plot command as before. Where do
you get the better fit, at the top or bottom of the
atmosphere?
 function c1x+c2, set up an overdetermined sys- tem Vc=T. The coefficient

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!