Fitting 3d data
3 views (last 30 days)
Show older comments
Good morning I'm using Matlab and i have a problem I have a series of points with xyz coordinates like A(1,0,5) etc etc and i want to find the best curve fitting those points and the equation for that curve Can someone please help me write a code for that? Thank you
7 Comments
John D'Errico
on 14 Jun 2017
Really? The ONLY one? The only possible one? Infinitely many. All equally valid. Walter does speak the truth here.
You need to first learn about curve fitting and modeling. Since you have not explained what you are trying to do, just uttered some vague words that don't really tell us anything, we cannot easily help you. That means you need to start learning about all the possible methods yourself. What tools? What model? You need to figure that all out, yourself. At least that is true if you cannot explain the problem more clearly that someone has a chance to help you.
OR...
You can explain yourself. CLEARLY tell us what you have. A picture is always a good idea. Some data, attached as a .mat file to a comment is way better. That way someone can play with your data and show how to do the task as an example. If there is some pertinent information that you have, then tell us.
Walter Roberson
on 14 Jun 2017
"there will be only one because the 3-D curve i'm trying to find is the only one that includes all 20 the 2-D curves I have"
Sort (with unique) all of the x coordinates. Find the difference between adjacent coordinates. As there are a finite number of coordinates, if there are at least two different x, you will be able to find a number that divides all of the differences, similar to a greatest common divisor. Call this F; call the smallest x as x0. Now take whatever formula you had in mind as being "the" correct model, and add to the model sin(Pi*F*(x-x0)) . By construction, the sin() will be 0 at x0 and with F being a divisor of all of the differences, the sin() will also be 0 at every original x in the model. Therefore this new term will give values that agree exactly with the known data at every known x value. This is a new formula that agrees with the data as well as the original proposed formula does. We have now reached a contradiction on the supposition that the original model formula was unique in exactly describing the known data. Now construct another new model that instead adds sin(Pi*2*F*(x-x0)), and another that adds sin(Pi*3*F*(x-x0)) and so on. Clearly there are an infinite number of these that can be added. Therefore given any one formula that fits the data exactly, there are an infinite number of formulae that fit the data exactly. QED.
Answers (0)
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!