Fitting 3D data into a function

22 views (last 30 days)
I have some data that I want to fit in a function. To be more clear, the data points depend on time, as well as the the radial and longitudinal coordinate. I would like to fit these data points into a function of the form f(r, z, t). I know I can fit data into a surface using fitobject = fit([x,y],z,fitType). However, I need a function in the form of fitobject = fit([x,y,z],f,fitType). Is there such a thing in Matlab? I failed to find it. Preferably, I would like to fit it into a polynomial.

Accepted Answer

John D'Errico
John D'Errico on 15 May 2023
The curve fitting toolbox does not fit models with more than 2 independent variables.
You can use my polyfitn tool, found on the file exchange, to fit a polynomial model in multiple dimensions.

More Answers (1)

Image Analyst
Image Analyst on 15 May 2023
Have you tried the Regression Learner app on the apps tab of the tool ribbon? You give it a set of input predictors, and a set of ground truth response values (the "true" values that you are going to train the model with) and then you can test a wide variety of models with it. You can choose the best model, which might or might not be a polynomial, and you might not have an analytical function/formula to write down, but that should not matter. All that matters is if you put in a set of predictors, you get a reasonable estimate for what the "true" value should be.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

Community Treasure Hunt

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

Start Hunting!