How to find the best fit to a set of data?

2 次查看(过去 30 天)
Syeda
Syeda 2013-8-31
评论: Syeda 2013-11-30
I have discrete regular grid of a-b points and their corresponding “c” values and I interpolate it further to get a smooth curve. Now from interpolation data, I further want to create a polynomial equation for curve fitting. How to fit 3D plot in polynomial?
I try to do this in MATLAB. I used Surface fitting toolbox in MATLAB (r2010a) to curve fit 3 dimensional data. But, how does one find a formula that fits a set of data to the best advantage in MATLAB. Any advise?
This is just a small portion of my data.
a = [ 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001,0.011, 0.011, 0.011, 0.011, 0.011, 0.011, 0.011, 0.011, 0.011, 0.011];
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
c = [ -.304860225, .170315374, .343019354, .370114906, .373180536, .36719579, .363397853, .363417755, .366962504, .379710865, -.304860225, .170315374, .343019354, .370114906, .373180536, .36719579, .363397853, .363417755, .366962504, .379710865];
Thanks in advance.
  3 个评论
James Phillips
James Phillips 2013-11-28
So that you can visually inspect the resulting fitted surface, I also made a 3D animation of the fitted surface and data rotating in 3-space:
The animated GIF is 6.6 Meg.
James
Syeda
Syeda 2013-11-30
Please check your mailbox! Thankyou for replying

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2013-8-31
First of all, you have 2D data. You do not have 3D data. You have 2 independent variables, which can each be an index in a matrix, and for those you have one value. This is a 2D array, not 3D because you do not have 3 independent variables. Sure you can plot it with surf() and it looks kind of 2.5D-ish since it's a perspective projection of a surface displayed on your flat 2D monitor, but that's still 2D not 3D.
That said, you can use John D'Errico's polyfitn(): http://www.mathworks.com/matlabcentral/fileexchange/34765-polyfitn That's what I use to fit a nice smooth polynomial to a non-uniform background image. This will give me a nice smooth background image free from any video noise since it's a model, not actual noisy image data.
By the way, there does not appear to be a "Surface Fitting Toolbox." If you're actually using the Curve Fitting Toolbox, then please add that the the product list to the bottom right of your original question.
  1 个评论
Syeda
Syeda 2013-9-5
编辑:Syeda 2013-9-5
I tried John D'Errico's polyfitn()
p = polyfitn([a(:),b(:)],c(:),3) % generates the coefficients of third degree polynomial
polyn2sym(p)
(This results may not be accurate, as it is just a small portion of my data)
Anyways, it gives me an equation.
Now, I want to plot the real data and the curve we created to fit the data. I want plot to compare fit with original data. Any advice?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Fit Postprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by