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

2 views (last 30 days)
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) ;

Accepted Answer

Walter Roberson
Walter Roberson on 18 Nov 2017
solution = fzero(fun2, 0.01) ;
or
solution = fzero(@(Cpk_hat) fun2(Cpk_hat), 0.01) ;
  5 Comments
Walter Roberson
Walter Roberson on 19 Nov 2017
fzero can only solve functions that cross zero. Your function does not cross zero.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!