How to find the best fit to a set of data?
3 views (last 30 days)
Show older comments
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 Comments
James Phillips
on 28 Nov 2013
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
Answers (1)
Image Analyst
on 31 Aug 2013
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.
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!