polyfit

12 次查看(过去 30 天)
12ar.af
12ar.af 2011-9-27
评论: Gabriela 2023-9-28
Hi guys, i have a question on polyfit. i have a set of data from a profile a picture, so know i want to use polyfit from 3rd degree to tenth degree to find which degree best fits the data so that it looks similar to the picture. can somebody help me pliz...
  2 个评论
Jan
Jan 2011-9-27
Please explain, what the problem is. Just try the different degrees and compare them with the original data. Then decide for a method to define "more similar": minimal sum of differences, minimal maximal difference, minimal difference of sum of position and 1st derivative, etc.
12ar.af
12ar.af 2011-9-30
can i use spline?

请先登录,再进行评论。

回答(2 个)

UJJWAL
UJJWAL 2011-9-27
Hi,
Kindly go to MATLAB and open the curve fitting toolbox. there select the data you want to fit and then clicking on the fitting button select a polynomial function and click on apply to fit the data Hope it helps. For details mail back
HAPPY TO HELP
UJJWAL
  2 个评论
UJJWAL
UJJWAL 2011-9-27
The Method is like this
a) Open the curve Fitting toolbox.
b)click on DATA...
c) Select the variables in the workspace that represtn the x and y-axis data and then click on create new data set.
d) Now Click on Ok and then click on Fitting... which is next to Data...
e) In the Type of Fit combo box select Custom Equations and then click on New.
f)A New window will open and there select the tab corresponding to General Equations.
g) Corresponding to the dependent variable y type the equation like cos(a*x+b).
h) As you will write the constants like a and b they will appear in the table below. You can also modify their starting points and their upper and lower limits. If you have any idea of these quantities depennding upon the nature of your program and your requirements then change them accordingly or let MATLAB handle the issue. It will just take some extra time.
Now CLick ok to go back to the previous window.
i) Click on Apply. MATLAB will compute the appropriate values of the constants and display them in the same wiundow under the title results. It will show the values of the constants you have provided computed in the least squares sense.
Gabriela
Gabriela 2023-9-28
Hello! Thanks you this is so helpful! Do you know how I can get the equation to remain on the plot? Once I switch to different data or if i close the fitting toolbox it dissapears.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2011-9-30
Sure you can use spline, but you specifically asked about polynomial fitting over the whole data (which is what polyfit does). Spline is defined through piecewise polynomials -- a different polynomial is used at every original point. Splines are pleasing to the eye, but useless at fitting a single function to the entire set of data, and seldom useful at extrapolating to points to the left or right of the given dataset.
There are an infinite number of different possible functions that precisely fit any finite set of data. That is infinite as in "uncountably large number", not just as an exaggeration for "a very large but fundamentally computable number". And if you say that there might be measurement error in the data such as from being limited to 53 bits of precision, then the only reason you do not have "more" polynomials to content with is that infinity times billions is still infinity.
Fundamentally fitting any particular function form (such as a polynomial) to a finite set of data is a more or less worthless thing to do unless you have prior knowledge that the data was generated by a process that has the characteristics of that function form. You have a better chance of picking the winning numbers in a major lottery than you have of picking the right function form for data created by an unknown process.

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by