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

3 visualizzazioni (ultimi 30 giorni)
Syeda
Syeda il 31 Ago 2013
Commentato: Syeda il 30 Nov 2013
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 Commenti
James Phillips
James Phillips il 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
Syeda
Syeda il 30 Nov 2013
Please check your mailbox! Thankyou for replying

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 31 Ago 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.
  1 Commento
Syeda
Syeda il 5 Set 2013
Modificato: Syeda il 5 Set 2013
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?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by