Clear Filters
Clear Filters

Triple integral using integral3

13 views (last 30 days)
DM on 24 Nov 2014
Commented: Roger Stafford on 24 Nov 2014
The following is a triple integral I am trying to compute using MATLAB, (please check link for clear illustration)
syms a
syms b
syms c
fabc= (a+b+c)*exp(a+b+c);
f=matlabFunction(fabc) % @(a,b,c)
cmin= @(a,b) b;
Is the code correct? Please note that this is not my real function but I wrote an easy one for purpose of illustration...

Answers (1)

Roger Stafford
Roger Stafford on 24 Nov 2014
The 'integral3' function performs numerical integration for which numerical values must be supplied. The form of your code looks correct for numerical integration except that the 'syms' lines should be removed.
If you want to perform symbolic triple integration, you will have to construct it using the 'int' function in triple form - that is, use it to integrate with respect to 'c' first, then use the answer to integrate with respect to 'b', and finally use that answer to integrate with respect to 'a'. You should be prepared for the possibility of exceedingly long answers with a symbolic triple integral. It may be advisable to apply the 'simplify' command in between the above steps to avoid needless complexity in your answer.
DM on 24 Nov 2014
Thanks, but if I remove the syms line, MATLAB cannot recognize the variables a,b,c. Right?
Roger Stafford
Roger Stafford on 24 Nov 2014
That's not necessarily true. To use 'integral3' what you must provide are the numerical values of all parameters that are used to define your integrand function and any numerical values involved in integration limits. In your case there are apparently none of this latter kind, but you may well have numerical parameters in your actual integrand function.
One further note: If you attempt to do symbolic integration instead, you should also be aware that 'int' can easily fail to find an explicit solution. It all depends on the nature of the integrand function and the integration limits. If you took integral calculus, you probably learned that there are many functions whose integrals don't show up in any integral tables, simply because they are unknown to mathematics.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!