Anonymous Function and Integration

I want to solve an eqution with an anonymous function and integration like this,
C=1; n=10; alpha=0.05;
Cp=C+0.33;
fY=@(y) normpdf(y+3*(Cp-C)*n^0.5,0,1)+normpdf((y-3.*(Cp-C).*n^0.5),0,1);
G=@(y,c1) chi2cdf(((n-1)*((3*Cp*n^0.5-y).^2)./(9*n*c1.^2)),n-1);
GY=@(c1) fY(y).*G(y,c1);
pv=@(c1) integral(GY,0,3*Cp*sqrt(n))-alpha;
c0=feval(pv,1.26);
But it shows "Undefined function or variable 'y'."
And I tried syms y still can't work and shows "Unable to prove '(37778931862957161709568*(y - 7103014205373209/562949953421312)^2)/18023676507955 < 0' literally. Use 'isAlways' to test the statement mathematically."
I don't know where the question is, please help me

4 Comments

GY=@(c1) fY(y).*G(y,c1);
y is not defined anywhere for that line.
Thanks that, I modified the last three, but it stil goes wrong
GY=@(c1,y) fY(y).*G(y,c1);
pv=@(c1,y) integral(GY(c1,y),0,3*Cp*sqrt(n))-alpha;
c0=feval(pv(c1,y),1.26);
Undefined function or variable 'c1'.
i want to solve c1, but why should I define c1 first?
Are you trying to solve for the c1 such that the integral equals 1.26 ? Are you trying to create a formula using the integral and evaluate the formula at 1.26 ? 1.26 for which variable?
1.26 is the guess for c1
I want to solve the equation in this picture
1569471616998.jpg

Sign in to comment.

 Accepted Answer

GY = @(c1,y) fY(y).*G(y,c1);
pv = @(c1) integral( @(y) GY(c1,y), 0, 3*Cp*sqrt(n));
c0_guess = 1.26;
c0 = fsolve( @(c1) pv(c1) - alpha, c0_guess);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!