How to use integral() in a multi variable expression?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 5 Feb. 2017
You would have to use the symbolic toolbox
syms x1 x2
int(a([x1,x2]), x1, LowerBound, UpperBound)
2 Kommentare
Walter Roberson
am 6 Feb. 2017
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)
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!