How to Double-integrate a Function with Three Variables Using quad2d

I have a question regarding double integration in MATLAB. I have three variables x, y, and z in the function I want to integrate, but want to integrate on x and y only. I am expecting the resulting equation to be a function of z, which may be more like a simplify function.
>> fun =@(x,y,z) 1/4.*max(x-(1+z)*y, 0); >> integral_fun = quad2d(fun,0,2,0,2) ??? Input argument "z" is undefined.
Error in ==> @(x,y,z)1/4.*max(x-(1+z)*y,0)
Error in ==> quad2d>tensor at 355 Z = FUN(X,Y); NFE = NFE + 1;
Error in ==> quad2d at 169 [Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Please help me out. Thank you.

 채택된 답변

Roger Stafford
Roger Stafford 2013년 6월 5일

1 개 추천

You cannot use a numerical integration function like 'quad2d' to produce results which contain unspecified variables. That is the role played by the 'int' function of the Symbolic Toolbox. However, it should be understood that with 'int' you are not always assured of obtaining an answer; there are no known explicit answers to a great many integration problems. In the particular case you describe you would well have trouble with 'int' due to presence of the 'max' function. (My own version failed on it miserably, as I anticipated.)

댓글 수: 1

Thank you so much! I guess I need to find another way to get around the 'max' function now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by