The fit() function allows fitting a surface to 3D data, where regularly spaced x,y data values specify a "grid" location and the z value specifies a surface "height". The fitted surface can be expressed as a polynomial of up to degree 5 in x and y.
Is there a means of fitting a model (polynomial or otherwise) to 4D data? In this case, the x,y,z data values specify a location (regularly spaced, within a unit cube for example), and w specifies a value at that location. Such data expresses a 3D "field" rather than a surface.
Thanks, mitch

 Respuesta aceptada

Matt J
Matt J el 13 de Sept. de 2023

0 votos

Yes, you can use lsqcurvefit.

3 comentarios

Mitch
Mitch el 14 de Sept. de 2023
Movida: Matt J el 14 de Sept. de 2023
Thanks Matt!
Looking at the documentation for lsqcurvefit(), I see only 1D curve fitting examples. Do you know of any multi-dimensional fitting examples I can look at? I'm new to Matlab, and it's hard to know exactly how to write the necessary commands without a simple/clear example.
Thanks, mitch
Matt J
Matt J el 14 de Sept. de 2023
Editada: Matt J el 14 de Sept. de 2023
Do you know of any multi-dimensional fitting examples I can look at?
Here's an example I just made up. The unknown parameter vector to be recovered is w:
xyz=rand(100,3); %fake x,y,z data
w=[1,2,3]; %ground truth parameters
F=vecnorm(xyz.*w,2,2); %fake dependent data
F=F+randn(size(F))*0.05; %add noise
wfit=lsqcurvefit(@modelFcn,[1,1,1], xyz,F)
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
wfit = 1×3
1.0162 1.9904 2.9886
function Fpred=modelFcn(w,xyz)
Fpred=vecnorm(xyz.*w,2,2);
end
Anyway, the point is that lsqcurvefit doesn't care about the dimensions of the data xyz and F. It only cares that your modelFcn returns a prediction Fpred of F as an array the same size as F.
Mitch
Mitch el 14 de Sept. de 2023
Okay, terrific Matt - thanks for that example. I think that will get me started on the right path.
Thanks again, mitch

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Etiquetas

Preguntada:

el 13 de Sept. de 2023

Comentada:

el 14 de Sept. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by