write a function in matlab that takes the vectors x and y as inputs where x and y co 5155488
Write a function in matlab that takes the vectors x and y as inputs, where x and y contain the values xi and yi, respectively, and a natural number n. The function will find the least-squares approximation with the basis functions fj(x) = xj-1, j = 1,…,n, and returns the vector a of the regression parameters aj and the value of the minimum total squared error E. Use the function for input variables x = 1:length(vec), y = vec, and n=1 where 'vec' is a vector. Include a plot of the input data points and the resulting estimation function ŷ(x).