fun(@x)

조회 수: 73 (최근 30일)
aymos
aymos 2018년 6월 26일
댓글: Walter Roberson 2021년 2월 27일
Hi,
I have a semilog graph which must be fitted (in its linear region) using this equation: y = 6e17*B*log[(x+B)/B]
Can you please tell how can I obtain the value of constant B, using fun(@x) ?
Thank you so much in advance for your help !
  댓글 수: 2
Rik
Rik 2018년 6월 26일
You should look into the fit function.
aymos
aymos 2018년 6월 26일
Can you please be more elaborate ?

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

답변 (2개)

Ameer Hamza
Ameer Hamza 2018년 6월 26일
편집: Ameer Hamza 2018년 6월 26일
If you have a vector of x and y values then you can use several functions to estimate B. The correct method to use depending on your definition of the error function. For example, if you want to estimate B by minimizing the MSE (mean square error) then use lsqcurvefit(). For example,
xdata = ...; % vector of x values
ydata = ...; % vector of y values
y = @(B, x) 6e17*B.*log((x+B)./B);
B_estmated = lsqcurvefit(y, 1, xdata, ydata);
^ initial point for the numerical optimization algorithm.
Similarly, if you have some other error function, then you can use fmincon().
  댓글 수: 11
aymos
aymos 2018년 6월 27일
Thanks Ameer.. and by what variable are you defining the predicted output ? (you are using y for both predicted and actual output?)
[~, y] = ode45(@(t,y) odefun(A, B, C, y), t, y0);
Ameer Hamza
Ameer Hamza 2018년 6월 27일
Yes, this equation will give the predicted output y. Also, I realize that using one y together in one statement can be a bit confusing but this syntax is correct. MATLAB does not confuse both y's with each other. You can change either one of the y to another variable name to avoid confusion.

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


abdul aleem shaik
abdul aleem shaik 2021년 2월 27일
I=a1+a2+a3 how to express this in terms of I = fun(ai)
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 2월 27일
I = @(ai) sum(ai)

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

카테고리

Help CenterFile Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by