How can I use integral to solve a equation with two function handle?

1 次查看(过去 30 天)
Hello, I want to solve the equation below solution = fzero(@(Cpk_hat) fun2,0.01) but I get the feedback :
'Undefined operator '==' for input arguments of type 'function_handle'.'
Error in fzero (line 314)
if fx == 0
Does anyone can tell me how to solve the problem?
thanks!
===========================================below is my code ======================================
n = 150;
w = 1.33;
p = 0.95;
s = 0.00969;
delta = 0.103;
alpha = ( n-1 )/2; beta = ( ((n-1)*s^2)./2 )^-1;
b1_of_y = @(y) 3*sqrt(n)*( Cpk_hat*sqrt( 2./((n-1)*y)) - w );
b2_of_y = @(y) 3*sqrt(n)*( (Cpk_hat + 2*delta./3)*sqrt( 2./((n-1)*y)) - w );
fun = @(y,Cpk_hat) ( (1./( gamma(alpha).*(y.^(alpha+1)) ) ).*exp(-1./y).*( normcdf(b1_of_y,0,1))+normcdf(b2_of_y,0,1) - 1);
fun2 = @(Cpk_hat) integral(@(y) fun,0,inf) - p ;
solution = fzero(@(Cpk_hat) fun2,0.01) ;

采纳的回答

Walter Roberson
Walter Roberson 2017-11-18
solution = fzero(fun2, 0.01) ;
or
solution = fzero(@(Cpk_hat) fun2(Cpk_hat), 0.01) ;
  5 个评论
Walter Roberson
Walter Roberson 2017-11-19
Let me put it this way: with that formula, you are attempting to do the equivalent of
solution = fzero(@(Cpk_hat) -infinity, 0.01) ;
The value of Cpk_hat does not matter: whatever numeric value you give to Cpk_hat, the result of the integral is going to be -infinity . It will never equal 0.
Walter Roberson
Walter Roberson 2017-11-19
fzero can only solve functions that cross zero. Your function does not cross zero.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!