Filter löschen
Filter löschen

lscurve fit problem issue in Money Rivlin model

11 Ansichten (letzte 30 Tage)
SATYA PAL
SATYA PAL am 20 Feb. 2023
Kommentiert: Star Strider am 23 Feb. 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

Akzeptierte Antwort

Star Strider
Star Strider am 20 Feb. 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 Kommentare
SATYA PAL
SATYA PAL am 23 Feb. 2023
Thanks a lot Sir
Star Strider
Star Strider am 23 Feb. 2023
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by