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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter1: Fundamentals Of C++ Programming
Section1.1: Preliminary One: Unit Analysis
Problem 9E: (Oceanography) The pressure, P, exerted on an underwater object can be determined by this formula:...
icon
Related questions
Question

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]

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
All Pairs Shortest Path
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole