Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MATLAB function myfit that will be called from the command line like this: [coef, new_y, error_y] = myfit (X_list, Y_list) The function should

Write a MATLAB function myfit that will be called from the command line like this: [coef, new_y, error_y] = myfit (X_list, Y_list) The function should use polyfit to determine the best fit curve for the points in X_list and Y_list. The degree of the polynomial should be the smallest degree polynomial with an average error (the average value of the absolute value of the difference between the new y-coordinates and the original y-coordinates) less than 1. You function should return three outputs in the following order

the vector of coefficients of the polynomial

the vector of the new y-coordinates which is the polynomial evaluated at the original x-coordinates

the vector of the error magnitudes (absolute value) of the y-coordinates

Example Test Case:

X_list = [ 1, 3, 5, 7, 9] ; Y_list = [ 4.1054, 3.7485, 5.4772, 9.036, 15.68 ]; [coef,new_y,error_y]=myfit(X_list, Y_list) 

Should display this result in the command window

coef = 0.2827 -1.4053 5.3064 new_y = 4.1838 3.6349 5.3477 9.3222 15.5585 error_y = 0.0784 0.1136 0.1295 0.2862 0.1215 

Your code should work for any set of starting values. Do not include test cases, clear all, etc as part of your submission.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

Define the terms critical path, ES, and LF.

Answered: 1 week ago

Question

Express sin T as a fraction in simplest terms. V 18 U 24

Answered: 1 week ago

Question

here) and other areas you consider relevant.

Answered: 1 week ago