Question: MATLAB: why is this incorrect? In MATLAB, write a function named bestFit that takes as an argument a vector containing exp seconds). The goal of
In MATLAB, write a function named bestFit that takes as an argument a vector containing exp seconds). The goal of this function is to find the polynomial between the order of 2 and 8 that best fits the experimental data. tion data (collected once every 10 This function should call your curveFit function starting with an order of 2 and increase the order of the polynomial until a suitable fit is found To determine the su must create a vector containing all the possible times based on the length of the experimental data. Times start at 0, and increase by 10 for each subsequent value. The polyval function will return a vector of theoretical accumulation values for each time interval. of a polynomial, use the polyval function on the 10 second intervals covered by the experimental a data. You You can use your experimental values compared to the theoretical accumulation values from your call to polyval to determine how well your polynomial fits the data. Compute the difference vector by subtracting the vector of experimental accumulation values from the theoretical accumulation. Use this as the . Compute the average and standard deviation (std) of the difference vector. .Use the average and standard deviation to make a decision regarding the quality of the solution using that order using the three rules below. If the order is sufficient, return its coefficients. If not, try the next higher order. Do not exceed an order of n highest order computed. 8. If no suitable fit is found, return the 1. If the average error for the order n polynomial is greater than the order n-1 2. If the value of the average and 3. If no suitable solution is found, return the 8 order polynomial coefficients. omial, return the coefficients of the order n-1 polynomial. order polynomial polyn standard deviation are below 01 for an n order polynomial, return the coefficients of the n To test your function, call bestFit and pass it expdata1. Compare your coefficients to the ans variable below >> bestFit(expdata1) ans = 0.0002 16.0138 -30.4356 Submit your function below for grading 1 function k-bestFit(vector) a-length(vector); In MATLAB, write a function named bestFit that takes as an argument a vector containing exp seconds). The goal of this function is to find the polynomial between the order of 2 and 8 that best fits the experimental data. tion data (collected once every 10 This function should call your curveFit function starting with an order of 2 and increase the order of the polynomial until a suitable fit is found To determine the su must create a vector containing all the possible times based on the length of the experimental data. Times start at 0, and increase by 10 for each subsequent value. The polyval function will return a vector of theoretical accumulation values for each time interval. of a polynomial, use the polyval function on the 10 second intervals covered by the experimental a data. You You can use your experimental values compared to the theoretical accumulation values from your call to polyval to determine how well your polynomial fits the data. Compute the difference vector by subtracting the vector of experimental accumulation values from the theoretical accumulation. Use this as the . Compute the average and standard deviation (std) of the difference vector. .Use the average and standard deviation to make a decision regarding the quality of the solution using that order using the three rules below. If the order is sufficient, return its coefficients. If not, try the next higher order. Do not exceed an order of n highest order computed. 8. If no suitable fit is found, return the 1. If the average error for the order n polynomial is greater than the order n-1 2. If the value of the average and 3. If no suitable solution is found, return the 8 order polynomial coefficients. omial, return the coefficients of the order n-1 polynomial. order polynomial polyn standard deviation are below 01 for an n order polynomial, return the coefficients of the n To test your function, call bestFit and pass it expdata1. Compare your coefficients to the ans variable below >> bestFit(expdata1) ans = 0.0002 16.0138 -30.4356 Submit your function below for grading 1 function k-bestFit(vector) a-length(vector)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
