Effacer les filtres
Effacer les filtres

lscurve fit problem issue in Money Rivlin model

9 vues (au cours des 30 derniers jours)
SATYA PAL
SATYA PAL le 20 Fév 2023
Commenté : Star Strider le 23 Fév 2023
Hello,
I have got a function with respect to different variables. I want to make sum of that function with respect to the variables. my equations are
fun1=@(a,x1) a(1).*(2*x1-2./x1.^2)+a(2).*(2-2./x1.^3)+a(3).*(6* x1.^2-6*x1-6./x1.^4+6./x1.^3 +6./x1.^2-6)
and
fun2=@(a,x2) a(1).*(2*x2)+a(2).*(2*x2)+a(3).*(4*x2.^3)
I want to add fun1 and fun2
fun_sum= @(a,x1,x2) fun(a,x1)+ fun(a,x2)
now by applying lscurvefit I want values of a(1), a(2) and a(3)
I am looking forward for reply
  1 commentaire
SATYA PAL
SATYA PAL le 20 Fév 2023
please share the code if possible

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 20 Fév 2023
I am not certain what you want to do.
Two independent variables may require one or two dependent variables, however with only one dependent variable, it will need to be duplicated to two columns (assuming all data are column-oriented) —
fun1=@(a,x1) a(1).*(2*x1-2./x1.^2)+a(2).*(2-2./x1.^3)+a(3).*(6* x1.^2-6*x1-6./x1.^4+6./x1.^3 +6./x1.^2-6);
fun2=@(a,x2) a(1).*(2*x2)+a(2).*(2*x2)+a(3).*(4*x2.^3);
fun12 = @(a,x1x2) [fun1(a,x1x2(:,1)) fun2(a,x1x2(:,2))];
x1x2 = rand(12,2);
y1y2 = rand(12,2);
B0 = rand(3,1);
B = lsqcurvefit(fun12, B0, x1x2, y1y2) % Two Dependent Variables
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
B = 3×1
-0.0744 0.0176 -0.0004
y1y1 = [1 1].*y1y2(:,1); % Duplicate First Column
B = lsqcurvefit(fun12, B0, x1x2, y1y1) % One Dependent Variable, Duplicated
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
B = 3×1
-0.0865 0.0210 -0.0004
.
  20 commentaires
SATYA PAL
SATYA PAL le 23 Fév 2023
Thanks a lot Sir
Star Strider
Star Strider le 23 Fév 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Descriptive Statistics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by