Question: Write a MATLAB function that fits the least squares regression to a set of data in the form: y = a_0 z_0 (x) + a_1

Write a MATLAB function that fits the least squares regression to a set of data in the form: y = a_0 z_0 (x) + a_1 z_1 (x) + a_2 z_2 (x) Your function should accept as inputs the x and y values of the data being fitted as well as the three basis functions (assume they are vectorized) for the least squares regression. The function should output a vector containing the coefficients a_0, a_1, and a_2. The function should check to make sure that at least 3 data points were entered and that the x-and y- vector are the same length. The function should run regardless if x and y are entered as row or column vectors. The first line of the function is given function [a] = general Least squares(x, y, z0, z1, Z2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
