MATLAB Answers

symbolic input error in fzero function

16 ビュー (過去 30 日間)
Han
Han 2019 年 1 月 29 日
コメント済み: Torsten 2019 年 1 月 30 日
function x = ibetainc(y,z,w)
%Inverse of incomplete beta function betainc
zfun = @(x,z,w,y) betainc(x,z,w) - y;
x = fzero(zfun,[0 1],optimset('TolX',1e-5),z,w,y);
end
y = 0.9;
w = 5;
sym z
E = limit((1-ibetainc(y,z,w))*z,z,inf);
I want to calculate the "E". But there is the error.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Error using fzero (line 246)
FZERO cannot continue because user-supplied function_handle ==> @(x,z,w,y)betainc(x,z,w)-y failed with the error below.
Inputs must be real, full, and double or single.
Error in ibetainc (line 6)
x = fzero(zfun,[0 1],optimset('TolX',1e-5),z,w,y);
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Can I fix this error?
Thank you.

  0 件のコメント

サインイン to comment.

採用された回答

Alan Weiss
Alan Weiss 2019 年 1 月 29 日
Your objective function must accept a single scalar argument, not four arguments as you have specified.
Perhaps what you want is to give values to z, w, and y, and compute the single value x. In that case, follow the instructions in Passing Extra Parameters and rewrite your function this way:
function x = ibetainc(y,z,w)
%Inverse of incomplete beta function betainc
zfun = @(x) betainc(x,z,w) - y;
x = fzero(zfun,[0 1]);
end
The z argument must be a regular MATLAB double, not a symbolic variable. Take increasingly small values of z and see what happens.
y = 0.9;
w = 5;
ibetainc(y,0.1,w)
ans =
0.0567
ibetainc(y,0.01,w)
ans =
3.3308e-06
ibetainc(y,0.001,w)
ans =
7.9936e-16
Alan Weiss
MATLAB mathematical toolbox documentation

  3 件のコメント

Han
Han 2019 年 1 月 30 日
It's not the correct answer, but it is helpful.
Thank you very march
Stephen Cobeldick
Stephen Cobeldick 2019 年 1 月 30 日
"It's not the correct answer"
Why not? Can you show us what is incorrect in this answer?
Torsten
Torsten 2019 年 1 月 30 日
I does not give an answer on how to obtain the unknown limit.

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。

タグ


Translated by