Question
Problem Description: Read Chapter 15, General Linear Least-Squares and Nonlinear Regression, from Chapra's textbook. Using the same approach as was employed to derive Eqs. (14.15)
Problem Description: Read Chapter 15, "General Linear Least-Squares and Nonlinear Regression," from Chapra's textbook.
Using the same approach as was employed to derive Eqs. (14.15) and (14.16), derive the least-squares fit of the following model:
y = a1*x + a2*x^2
That is, determine the coefficients that result in the least-squares fit for a second-order polynomial with a zero intercept. Compare this result to a quadratic curve fit that includes an intercept value, a0.
y = a0 + a1*x + a2*x^2
Note: Your function needs to be able to handle sample data sets of arbitrary size.
GIven Code Need Matlab function
function [F_fit,a0,a1,a2,r2] = Chapra_15p2(n,v_sample,F_sample,v_fit)
% Input
% n: number of terms in the curve fit (scalar)
% n=2 for zero intercept,
% n=3 includes an intercept
% v_sample: sample velocity values (vector)
% F_sample: experimental data of force for sample velocity values (vector)
% v_fit: velocity values to evaluate fit of Force (vector)
%
% Output
% F_fit: Value of polynomial fit for Force (vector)
% evaluated at given velocity, v_fit
% a0: coefficient for value of y-intercept (scalar)
% a1: coefficient for value of slope (scalar)
% a2: coefficient for value of quadratic term (scalar)
% r2: Coefficient of determination (scalar)
%
% Write your code here.
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started