How can I use integral to solve a equation with two function handle?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Louis Liu
am 18 Nov. 2017
Kommentiert: Walter Roberson
am 19 Nov. 2017
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) ;
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 18 Nov. 2017
solution = fzero(fun2, 0.01) ;
or
solution = fzero(@(Cpk_hat) fun2(Cpk_hat), 0.01) ;
5 Kommentare
Walter Roberson
am 19 Nov. 2017
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
am 19 Nov. 2017
fzero can only solve functions that cross zero. Your function does not cross zero.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!