Integration numerical with variable limits
Show older comments
I am trying to find a double integration numerically where the inner integral has variable limits while the outer integral has scalar limits and not the other way round. As I understand integral2 allows you do the reverse of what I want i.e you can have the outer variable limits non scalar while the inner should be scalar.
fxy=@(x,y)1/x+1/y
xmin=0;
xmax=@(y)2*y;
ymin=0;
ymax=+inf;
integral2(fxy,xmin,xmax,ymin,ymax)
I get the following error
Error using integral2 (line 76)
XMAX must be a floating point scalar.
Accepted Answer
More Answers (2)
There is a general solution using symbolic tools.
syms x y
fxy=1./x+1./y;
xmin=0;
xmax=2*y;
ymin=0;
ymax=+inf
int(fxy,x,xmin, xmax) % integration dx
int(int(fxy,x,xmin, xmax),y,ymin,ymax) % double integration
Andrei Bobrov
on 3 Oct 2014
in your case:
out = integral2(fxy,ymin,ymax,xmin,xmax);
2 Comments
DM
on 3 Oct 2014
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!