Question
Notes: Use MATLAB to write code in order to solve the following questions. Your program code should be properly commented; your evaluation will include being
Notes:
Use MATLAB to write code in order to solve the following questions.
Your program code should be properly commented; your evaluation will include being able to explain your code.
Submission Items:
Submit MATLAB source (.m) file(s) and snapshot of the output and graph (copied in a single document file) when you run the program for the conditions mentioned in the questions below.
Question 1: [13 points]
Note: Do not use MATLAB build-in functions for regression.
Write a MATLAB function that accepts n values of xi and yi , perform Linear Regression and returns values of r2 and, the model parameters a0 and a1 .
Write another MATLAB function that accepts n values of xi and yi (provided as arrays), checks for Linear, Power and Saturation growth-rate models, and estimate the values of parameters a0 and a1 (or and , whichever is applicable). In all three methods, the function should use the function developed in part (a) to perform the linear regression part. Plot the data and the three models (one linear and two non-linear) on the same graph (use distinct colors/shades of lines to differentiate). The function should return a number from 1-3 indicating the model with the best fit, its r2, and the estimated values of parameters.
Call the function from the command window with the data given below, capture the image of the output showing the returned values, and the graph, and include these in the Word document for submission.
x 0.75 2 3 4 6 8 8.5
-------------------------------------------------------------------------------
y 1.2 1.95 2 2.4 2.4 2.7 2.6
Question 2: [7 points]
Write a MATLAB function that accepts (n +1) values of xi and yi , fits nth order polynomial, evaluate it for certain x value using Lagrange Interpolating Polynomial, and returns the value of y at x .
Call this function from the command window with the data given in Question 1, evaluate y at x=7 , and capture the image of the output.
Refer to Figure 18.11 for the Pseudocode of the method.
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