필터 지우기
필터 지우기

lscurve fit problem issue in Money Rivlin model

조회 수: 9 (최근 30일)
SATYA PAL
SATYA PAL 2023년 2월 20일
댓글: Star Strider 2023년 2월 23일
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

채택된 답변

Star Strider
Star Strider 2023년 2월 20일
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
SATYA PAL
SATYA PAL 2023년 2월 23일
Thanks a lot Sir
Star Strider
Star Strider 2023년 2월 23일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by