Regression of points with desired equation

조회 수: 2 (최근 30일)
Sergio RUGGIERI
Sergio RUGGIERI 2020년 6월 15일
댓글: Star Strider 2020년 6월 15일
Hi all,
Im trying to fit some points of established values, by using a regression made with an own equation (dependent from another parameter).
The points are defined as follow:
Xp=[4.5 5 5.5 6 ];
Yp=[0.7 0.9 0.85 1] ;
The form of the equation must be this:
Y= 2*(1 + tanh * ( ( X + a * Val2 - b ) / c ));
where Val2 is equal to 0.5.
My necessity is to define the terms a, b, c, which are unknown.
Thanks in advance

채택된 답변

Star Strider
Star Strider 2020년 6월 15일
Try this:
Xp=[4.5 5 5.5 6 ];
Yp=[0.7 0.9 0.85 1] ;
Val2 = 0.5;
Y = @(X,a,b,c,Val2) 2*(1 + tanh( ( X + a * Val2 - b ) ./ c ));
[Prms,rsdnrm] = fminsearch(@(b) norm(Yp - Y (Xp,b(1),b(2),b(3),Val2)), rand(3,1))
figure
plot(Xp, Yp, 'p')
hold on
plot(Xp, Y(Xp,Prms(1),Prms(2),Prms(3),Val2), '-r')
hold off
grid
.
  댓글 수: 2
Sergio RUGGIERI
Sergio RUGGIERI 2020년 6월 15일
Thanks, it works for me!!
Star Strider
Star Strider 2020년 6월 15일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by