EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • All Courses
    • All Specializations
  • Blog
  • Enterprise
  • Free Courses
  • All Courses
  • All Specializations
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab Double Integral
 

Matlab Double Integral

Priya Pedamkar
Article byPriya Pedamkar

Updated July 3, 2023

Matlab Double Integral

 

 

Introduction to Matlab Double Integral

Matlab Double Integral is the extension of the definite integral. In the double integral, the integration is carried out for functions that involve two variables. It is an extension of the concept of integration for functions with one variable. In MATLAB, we use ‘integral2 function’ to get the double integration of a function.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax

Let us now understand the syntax of integral2 function in MATLAB:

I = integral2 (Func, minX, maxX, minY, maxY)
I = integral2 (Func, minX, maxX, minY, maxX, Name, Value)

Explanation:

I = integral2 (Func, minX, maxX, minY, maxY) will integrate the function ‘Func’ (here ‘Func’ is a function of 2 variables X and Y) over the region minX ≤ X ≤ maxX and minY ≤ Y ≤ maxY

I = integral2 (Func, minX, maxX, minY, maxX, Name, Value) can be used to pass more options to the integral2 function. These options are passed as paired arguments

Examples to Implement Matlab Double Integral

Let us now understand the code to calculate the double integral in MATLAB using ‘integral2 function’.

Example #1

In this example, we will take a function of cos with 2 variables, ‘x’ and ‘y’. We will follow the following 2 steps:

Step 1: Create a function of x and y

Step 2: Pass the function and required limits to the integral2 function

Code:

Func = @ (x,y) (x + cos (y) + 1)
[Creating the cos function in ‘x’ and ‘y’] I = integral2 (Func, 0, 1, 0, 2)
[Calling the integral2 function and passing the desired limits as 0 <= x <= 1; 0 <= y <= 2)] [Mathematically, the double integral of x + cos (y) + 1 is 3.9093]

Output:

Matlab Double Integral1

Explanation: As we can see in the output, we have obtained a double integral of our input function as 3.9093, which is the same as we expected.

Example #2

In this example, we will take a function of sin with 2 variables, ‘x’ and ‘y’. We will follow the following 2 steps:

Step 1: Create a sin function of x and y

Step 2: Pass the function and required limits to the integral2 function

Code:

Func = @(x,y) (sin(y) + x.^3 + 2)
[Creating the sin function in ‘x’ and ‘y’] I = integral2 (Func, 0, 1, 0, 2)
[Calling the integral function and passing the desired limits as 0 <= x <= 1; 0 <= y <= 2)] [Mathematically, the double integral of sin(y) + x.^3 + 2 is 5.9161]

Output:

Matlab Double Integral2

Explanation: As we can see in the output, we have obtained a double integral of our input function as 5.9161, which is the same as we expected.

Example #3

We will take a polynomial function of x and y in this example. We will follow the following 2 steps:

Step 1: Create a polynomial function of x and y

Step 2: Pass the function and required limits to the integral2 function

Code:

Func = @(x,y) (35*y.^3 - 15*x)
[Creating the polynomial function in ‘x’ and ‘y’] I = integral2 (Func, 0, 1, 0, 2)
[Calling the integral function and passing the desired limits as 0 <= x <= 1; 0 <= y <= 2)] [Mathematically, the double integral of 35*y.^3 - 15*x is 125]

Output:

Matlab Double Integral3

Explanation: As we can see in the output, we have obtained a double integral of our input function as 125, which is the same as we expected.

Example #4

In this example, we will take a polynomial function of x, y, and degree 3. We will follow the following 2 steps:

Step 1: Create a polynomial function of x and y and degree 3

Step 2: Pass the function and required limits to the integral2 function

Code:

Func = @(x,y) ((20*y.^3) + 3*x.^2)
[Creating the polynomial function in ‘x’ and ‘y’] I = integral2 (Func, 0, 1, 0, 2)
[Calling the integral function and passing the desired limits as 0 <= x <= 1; 0 <= y <= 2)] [Mathematically, the double integral of (20*y.^3) + 3*x.^2 is 82]

Output:

Degree 3

Example #5

In this example, we will take a polynomial function with the division. We will follow the following 2 steps:

Step 1: Create a polynomial function of x and y with division

Step 2: Pass the function and required limits to the integral2 function

Code:

Func = @(x,y) 1./(sqrt(x.^3 + y.^2))
[Creating the polynomial function in ‘x’ and ‘y’ and division] I = integral2 (Func, 0, 1, 0, 2)
[Calling the integral function and passing the desired limits as 0 <= x <= 1; 0 <= y <= 2)] [Mathematically, the double integral of 1./(sqrt(x.^3 + y.^2))  is 2.9012]

Output:

polynomial function

Conclusion

Integral2 function can be used in MATLAB to get the double integral of a function. Double integral integrates the function of 2 variables over a 2-D region specified by the limits.

Recommended Articles

This is a guide to Matlab Double Integral. Here we discuss an introduction to Matlab Double Integral, syntax, and examples. You can also go through our other related articles to learn more –

  1. MATLAB cylinder()
  2. Matlab mesh()
  3. Matlab Figure
  4. Matlab sphere()
Primary Sidebar
Footer
Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW