Curve fitting for multivariable

xdata = ...
[0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937
];
xdata1 = ...
[0.906307787 0.906307787 0.906307787 0.866025404 0.866025404 0.866025404 0.866025404 0.866025404 0.866025404 0.707106781 0.707106781 0.707106781 0.707106781 0.707106781 0.707106781
];
xdata2 = ...
[6 7 8 3 4 5 6 7 8 3 4 5 6 7 8
];
xdata3 = ...
[0.886554928 0.835547334 0.81144197 0.87036842 0.874342998 0.879089205 0.866834625 0.875630457 0.891094548 0.935958471 0.930808554 0.940172751 0.905018613 0.895769734 0.895561329
];
F = @(x,xdata,xdata1,xdata2,xdata3)xdata*x(1)*exp(x(2)*xdata1+x(3)*xdata2+x(4)*xdata);
Which curve fitting function can I use to solve x(1) x(2) x(3) x(4)?

 Respuesta aceptada

Star Strider
Star Strider el 23 de Nov. de 2021
There are several options.
I’m using fminsearch here.
xdata = ...
[0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937 0.882263937
];
xdata1 = ...
[0.906307787 0.906307787 0.906307787 0.866025404 0.866025404 0.866025404 0.866025404 0.866025404 0.866025404 0.707106781 0.707106781 0.707106781 0.707106781 0.707106781 0.707106781
];
xdata2 = ...
[6 7 8 3 4 5 6 7 8 3 4 5 6 7 8
];
xdata3 = ...
[0.886554928 0.835547334 0.81144197 0.87036842 0.874342998 0.879089205 0.866834625 0.875630457 0.891094548 0.935958471 0.930808554 0.940172751 0.905018613 0.895769734 0.895561329
];
% F = @(x,xdata,xdata1,xdata2,xdata3)xdata*x(1)*exp(x(2)*xdata1+x(3)*xdata2+x(4)*xdata);
F = @(x,xdata)xdata(:,1).*x(1).*exp(x(2).*xdata(:,2)+x(3).*xdata(:,3)+x(4).*xdata(:,4));
xdatam = [xdata(:) xdata1(:) xdata2(:) xdata3(:)];
x0 = rand(4,1);
[B,fv] = fminsearch(@(x) norm(F(x,xdatam)), x0)
B = 4×1
32.6171 329.4611 -415.3622 0.9991
fv = 0
.

5 comentarios

Hoang Khanh Le
Hoang Khanh Le el 24 de Nov. de 2021
Thanks for your suggestion.
Hoang Khanh Le
Hoang Khanh Le el 24 de Nov. de 2021
May I ask you a question? If I also do not know the exponential function in the formula, how I can find a suitable function for these data set? thanks a lot
Star Strider
Star Strider el 24 de Nov. de 2021
As always, my pleasure!
With respect to fitting the model, I have no idea what model correctly describes the data. I have no idea what the data are, what they represent, or the process that created them. A mathematical model of the process that created them is the best function to fit to them. Use that if it is known.
There are several different solvers available. Use whatever works best. (I chose fminserarch because it is part of base MATLAB so everyone has it.)
.
Hoang Khanh Le
Hoang Khanh Le el 24 de Nov. de 2021
Your proposed function works very well, thanks a lot.
Star Strider
Star Strider el 24 de Nov. de 2021
As always, my pleasure!
.

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.

Preguntada:

el 23 de Nov. de 2021

Comentada:

el 24 de Nov. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by