Question: It is MATLAB problem Question has no problem1 , but the question 2 , the code Polyfit says I am wrong in Line9, why? It

 It is MATLAB problem Question has no problem1 , but thequestion 2 , the code "Polyfit" says I am wrong in Line9,why? It works in other line but seems not work in loop.

It is MATLAB problem

Question has no problem1 , but the question 2 , the code "Polyfit" says I am wrong in Line9, why?

It works in other line but seems not work in loop.

How should I edit

Here is the origin code

function k=bestFit(vector) k=123; q=curveFit(vector,2); average1=mean(diff(q)); if std(diff(q))average1 k=curveFit(vector,n-1); end if standard In MATLAB, write a function named curvefit that takes as arguments a vector containing the experimental accumulation data (collected once every 10 seconds) and an integer n representing the polynomial order, and fits a curve of the given order that most closely matches the data. You will use the polyfit function (https://www.mathworks.com/help/matlab/ref/polyfit.html) to fit an n order polynomial to the experimental accumulation data. Before calling polyfit, you must create a vector containing all the possible times based on the length of the experimental accumulation data. Times start at 0, and increase by 10 for each subsequent value. Your function should return a vector of coefficients for the specified polynomial. Submit your function below for grading. Answer. 1 function p=curvefit (vector,n) 2 a-length(vector); 3 b=(0:10:(a-1)*10); 4 x.b; 5 y=vector; 6 p=polyfit(x,y,n); 7 end Check

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!