How to use integral() in a multi variable expression?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi! How could I writte a code to integrate the expression in relation to x(1) only?
a = @(x)x(1) + x(2)^2;
댓글 수: 0
답변 (1개)
Walter Roberson
2017년 2월 5일
You would have to use the symbolic toolbox
syms x1 x2
int(a([x1,x2]), x1, LowerBound, UpperBound)
댓글 수: 2
Walter Roberson
2017년 2월 6일
That does use a function handle. It invokes the function handle a on the input [x1, x2], returning the symbolic expression x1 + x2^2 which is then integrated. If you need to turn the symbolic result back into a function handle then you can use matlabFunction .
If your question is whether you can use integral() to do an integral over one of the variables leaving the other undefined, then the answer is NO.
It is possible to do a 2D numeric integral using integral2(), such as
a = @(x)x(1) + x(2).^2; %vectorize it!
fa = @(x,y) a([x,y])
integral2(fa, xlow, xhigh, ylow, yhigh)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!