How to handle with double integral with complicated expressions?
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to do double integral with complicated expressions. simply , my code is that:
>> r=3;
>> t=2;
>> q= @(x,y) (x+(t./2)).^2+(x+(t./2)).*y.^2;
>> p = @(x,y) ((x+t)./2).^2+(x+(t./2)).*y.^2;
>> func = @(x,y) sqrt((q - x).^2 - r.^2) + asin(r.^2 - (p-x).^2);
>> y_min = @(x) sqrt(r.^2 - (x-t).^2);
>> y_max = @(x) sqrt(r.^2-(x-((t./2)-r)).^2);
after these codes, then I add this statement for double integral.
>> integral2(func, 0, t./2, y_min, y_max)
and I have this kinds of error messages.
함수 'minus'은(는) 'function_handle'형 입력 인수에 대해 정의되지 않았습니다.
오류 발생: @(x,y)sqrt((q-x).^2-r.^2)+asin(r.^2-(p-x).^2)
오류 발생: integral2Calc>integral2t/tensor (line 228) Z = FUN(X,Y); NFE = NFE + 1;
오류 발생: integral2Calc>integral2t (line 55) [Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
오류 발생: integral2Calc (line 9) [q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
오류 발생: integral2 (line 106) Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);
sorry for some Koreans.
how can I solve this problem?
댓글 수: 0
답변 (1개)
Orion
2014년 11월 13일
Hi,
you defined q and p as function handles, and then you use them inside another function handle func.
in func you're asking to do a minus operation between x which will be a numerical parameter and q which is a function handle. this is a non-sense, that's the reason you get an error
Undefined function 'minus' for input arguments of type 'function_handle'.
just write func in one big line, replacing q and p with their expression.
func = @(x,y) sqrt(((x+(t./2)).^2+(x+(t./2)).*y.^2 - x).^2 - r.^2) + asin(r.^2 - (((x+t)./2).^2+(x+(t./2)).*y.^2-x).^2);
this way it will work.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!