Write a function that solves the general linear least-squares problem. The inputs to your function should be a vector of a values, a vector of measured y values, and an anonymous function that calculates a single row of the Z matrix. Inside your function, use the inputted anonymous function to create Z row-by-row, then use Z to create the normal equations. Solve these normal equations to obtain the computed coefficients that define the best-fit of your model. Your function should output these calculated coefficients. Again, include an error check that makes sure the input vectors are the same size. You may not use any built-in MATLAB functions to solve the normal equation. You can use any functions you have developed solves Ax = b via LU-decomposition is one option. e.g. a function you have that
5. (a) Write a function that solves the general linear least-squares problem. The inputs to your function should be a vector of a values, a vector of measured y values, and an anonymous function that calculates a single row of the Z matrix. Inside your function, use the inputted anonymous function to create Z row-by-row, then use Z to create the normal equations. Solve these normal equations to obtain the computed coefficients that define the best-fit of your model. Your function should output these calculated coefficients. Again, include an error check that makes sure the input vectors are the same size. You may not use any built-in MATLAB functions to solve the normal equation. You can use any functions you have developed solves Ax = b via LU-decomposition is one option. e.g. a function you have that
(b) Test your function in (a) to fit the following model to the given dataset (see belo
y = a + bx
(c) Test your function in (a) to fit the following model to the given dataset (see belo
y=a+br
+ d
2
20
0
1
3
2
5
6
6
8
5
2 3 4 5 6 7 8 9 10] 7.1 8.2 9.4 11.
y=[2
2
4
11.3 15.6 22] .5.8.20].5.8.7.6.5.4.6.3.8.11=12r+i+w) +w).0]
y=[2.2
2.8
4.5
11.3 15.6 22]
Trending now
This is a popular solution!
Step by step
Solved in 2 steps