SlideShare a Scribd company logo
http://www.tutorialspoint.com/matlab/matlab_integ ration.htm Copyright © tutorialspoint.com
MATLAB - INTEGRATION
Integrationdeals withtwo essentially different types of problems.
Inthe first type, derivative of a functionis givenand we want to find the function. Therefore, we basically
reverse the process of differentiation. This reverse process is knownas anti-differentiation, or finding the
primitive function, or finding anindefinite integral.
The second type of problems involve adding up a very large number of very smallquantities and then
taking a limit as the size of the quantities approaches zero, while the number of terms tend to infinity. This
process leads to the definitionof the definite integral.
Definite integrals are used for finding area, volume, center of gravity, moment of inertia, work done by a force,
and innumerous other applications.
Finding Indefinite Integral Using MATLAB
By definition, if the derivative of a functionf(x) is f'(x), thenwe say that anindefinite integralof f'(x) withrespect to
x is f(x). For example, since the derivative (withrespect to x) of x2 is 2x, we cansay that anindefinite integralof
2x is x2.
Insymbols:
f'(x2) = 2x, therefore,
∫ 2xdx = x2.
Indefinite integralis not unique, because derivative of x2 + c, for any value of a constant c, willalso be 2x.
This is expressed insymbols as:
∫ 2xdx = x2 + c.
Where, c is called an'arbitrary constant'.
MATLAB provides anint command for calculating integralof anexpression. To derive anexpressionfor the
indefinite integralof a function, we write:
int(f);
For example, fromour previous example:
syms x
int(2*x)
MATLAB executes the above statement and returns the following result:
ans =
x^2
Example 1
Inthis example, let us find the integralof some commonly used expressions. Create a script file and type the
following code init:
syms x n
int(sym(x^n))
f = 'sin(n*t)'
int(sym(f))
syms a t
int(a*cos(pi*t))
int(a^x)
Whenyourunthe file, it displays the following result:
ans =
piecewise([n == -1, log(x)], [n ~= -1, x^(n + 1)/(n + 1)])
f =
sin(n*t)
ans =
-cos(n*t)/n
ans =
(a*sin(pi*t))/pi
ans =
a^x/log(a)
Example 2
Create a script file and type the following code init:
syms x n
int(cos(x))
int(exp(x))
int(log(x))
int(x^-1)
int(x^5*cos(5*x))
pretty(int(x^5*cos(5*x)))
int(x^-5)
int(sec(x)^2)
pretty(int(1 - 10*x + 9 * x^2))
int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2)
pretty(int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2))
Note that the pretty command returns anexpressionina more readable format.
Whenyourunthe file, it displays the following result:
ans =
sin(x)
ans =
exp(x)
ans =
x*(log(x) - 1)
ans =
log(x)
ans =
(24*cos(5*x))/3125 + (24*x*sin(5*x))/625 - (12*x^2*cos(5*x))/125 + (x^4*cos(5*x))/5 -
(4*x^3*sin(5*x))/25 + (x^5*sin(5*x))/5
2 4
24 cos(5 x) 24 x sin(5 x) 12 x cos(5 x) x cos(5 x)
----------- + ------------- - -------------- + ----------- -
3125 625 125 5
3 5
4 x sin(5 x) x sin(5 x)
------------- + -----------
25 5
ans =
-1/(4*x^4)
ans =
tan(x)
2
x (3 x - 5 x + 1)
ans =
- (7*x^6)/12 - (3*x^5)/5 + (5*x^4)/8 + x^3/2
6 5 4 3
7 x 3 x 5 x x
- ---- - ---- + ---- + --
12 5 8 2
Finding Definite Integral Using MATLAB
By definition, definite integralis basically the limit of a sum. We use definite integrals to find areas suchas the area
betweena curve and the x-axis and the area betweentwo curves. Definite integrals canalso be used inother
situations, where the quantity required canbe expressed as the limit of a sum.
The int command canbe used for definite integrationby passing the limits over whichyouwant to calculate the
integral.
To calculate
we write,
int(x, a, b)
For example, to calculate the value of we write:
int(x, 4, 9)
MATLAB executes the above statement and returns the following result:
ans =
65/2
Following is Octave equivalent of the above calculation:
pkg load symbolic
symbols
x = sym("x");
f = x;
c = [1, 0];
integral = polyint(c);
a = polyval(integral, 9) - polyval(integral, 4);
display('Area: '), disp(double(a));
Analternative solutioncanbe givenusing quad() functionprovided by Octave as follows:
pkg load symbolic
symbols
f = inline("x");
[a, ierror, nfneval] = quad(f, 4, 9);
display('Area: '), disp(double(a));
Example 1
Let us calculate the area enclosed betweenthe x-axis, and the curve y = x3−2x+5 and the ordinates x = 1 and x =
2.
The required area is givenby:
Create a script file and type the following code:
f = x^3 - 2*x +5;
a = int(f, 1, 2)
display('Area: '), disp(double(a));
Whenyourunthe file, it displays the following result:
a =
23/4
Area:
5.7500
Following is Octave equivalent of the above calculation:
pkg load symbolic
symbols
x = sym("x");
f = x^3 - 2*x +5;
c = [1, 0, -2, 5];
integral = polyint(c);
a = polyval(integral, 2) - polyval(integral, 1);
display('Area: '), disp(double(a));
Analternative solutioncanbe givenusing quad() functionprovided by Octave as follows:
pkg load symbolic
symbols
x = sym("x");
f = inline("x^3 - 2*x +5");
[a, ierror, nfneval] = quad(f, 1, 2);
display('Area: '), disp(double(a));
Example 2
Find the area under the curve: f(x) = x2 cos(x) for −4 ≤ x ≤ 9.
Create a script file and write the following code:
f = x^2*cos(x);
ezplot(f, [-4,9])
a = int(f, -4, 9)
disp('Area: '), disp(double(a));
Whenyourunthe file, MATLAB plots the graph:
and displays the following result:
a =
8*cos(4) + 18*cos(9) + 14*sin(4) + 79*sin(9)
Area:
0.3326
Following is Octave equivalent of the above calculation:
pkg load symbolic
symbols
x = sym("x");
f = inline("x^2*cos(x)");
ezplot(f, [-4,9])
print -deps graph.eps
[a, ierror, nfneval] = quad(f, -4, 9);
display('Area: '), disp(double(a));
Ad

More Related Content

What's hot (20)

CGM-B-SPLINE CURVE.pptx
CGM-B-SPLINE CURVE.pptxCGM-B-SPLINE CURVE.pptx
CGM-B-SPLINE CURVE.pptx
SubhashreePradhan46
 
Introduction to PTV Vistro
Introduction to PTV VistroIntroduction to PTV Vistro
Introduction to PTV Vistro
Jongsun Won, PE
 
Numerical differentiation integration
Numerical differentiation integrationNumerical differentiation integration
Numerical differentiation integration
Tarun Gehlot
 
Cohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksCohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marks
Rehan Khan
 
Vertical alignment
Vertical alignmentVertical alignment
Vertical alignment
Ghulam Murtaza
 
02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...
02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...
02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...
Hossam Shafiq I
 
Class 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptxClass 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptx
MdSiddique20
 
Informed search algorithms.pptx
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
Dr.Shweta
 
Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah)
Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah) Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah)
Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah)
Hossam Shafiq I
 
Traffic signal design (1)
Traffic signal design (1)Traffic signal design (1)
Traffic signal design (1)
Syed Ali
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
Ankur Kumar
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curve
Arvind Kumar
 
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPTHOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Ahtesham Ullah khan
 
Adaptive cruise control
Adaptive cruise controlAdaptive cruise control
Adaptive cruise control
Jinu Joy
 
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
MUZAMILALI48
 
Report on rsa for rural road
Report on rsa for rural roadReport on rsa for rural road
Report on rsa for rural road
Pawan Kumar
 
Multivariable Optimization-for class (1).pptx
Multivariable Optimization-for class (1).pptxMultivariable Optimization-for class (1).pptx
Multivariable Optimization-for class (1).pptx
NehaJangir5
 
Finite Element Analysis - UNIT-2
Finite Element Analysis - UNIT-2Finite Element Analysis - UNIT-2
Finite Element Analysis - UNIT-2
propaul
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration method
shashikant pabari
 
Definition of automation,finite automata,transition system
Definition of automation,finite automata,transition systemDefinition of automation,finite automata,transition system
Definition of automation,finite automata,transition system
Dr. ABHISHEK K PANDEY
 
Introduction to PTV Vistro
Introduction to PTV VistroIntroduction to PTV Vistro
Introduction to PTV Vistro
Jongsun Won, PE
 
Numerical differentiation integration
Numerical differentiation integrationNumerical differentiation integration
Numerical differentiation integration
Tarun Gehlot
 
Cohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksCohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marks
Rehan Khan
 
02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...
02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...
02-A Components of Traffic System [Road Users and Vehicles] (Traffic Engineer...
Hossam Shafiq I
 
Class 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptxClass 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptx
MdSiddique20
 
Informed search algorithms.pptx
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
Dr.Shweta
 
Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah)
Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah) Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah)
Lecture 01 Introduction (Traffic Engineering هندسة المرور & Dr. Usama Shahdah)
Hossam Shafiq I
 
Traffic signal design (1)
Traffic signal design (1)Traffic signal design (1)
Traffic signal design (1)
Syed Ali
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
Ankur Kumar
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curve
Arvind Kumar
 
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPTHOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Ahtesham Ullah khan
 
Adaptive cruise control
Adaptive cruise controlAdaptive cruise control
Adaptive cruise control
Jinu Joy
 
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
MUZAMILALI48
 
Report on rsa for rural road
Report on rsa for rural roadReport on rsa for rural road
Report on rsa for rural road
Pawan Kumar
 
Multivariable Optimization-for class (1).pptx
Multivariable Optimization-for class (1).pptxMultivariable Optimization-for class (1).pptx
Multivariable Optimization-for class (1).pptx
NehaJangir5
 
Finite Element Analysis - UNIT-2
Finite Element Analysis - UNIT-2Finite Element Analysis - UNIT-2
Finite Element Analysis - UNIT-2
propaul
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration method
shashikant pabari
 
Definition of automation,finite automata,transition system
Definition of automation,finite automata,transition systemDefinition of automation,finite automata,transition system
Definition of automation,finite automata,transition system
Dr. ABHISHEK K PANDEY
 

Similar to Matlab integration (20)

Matlab differential
Matlab differentialMatlab differential
Matlab differential
pramodkumar1804
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
Matlab algebra
Matlab algebraMatlab algebra
Matlab algebra
pramodkumar1804
 
Matlab functions
Matlab functionsMatlab functions
Matlab functions
pramodkumar1804
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
Johan Tibell
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
pramodkumar1804
 
C sharp chap6
C sharp chap6C sharp chap6
C sharp chap6
Mukesh Tekwani
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
Devnology
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
SALU18
 
Matlab1
Matlab1Matlab1
Matlab1
guest8ba004
 
Столпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойСтолпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай Мозговой
Sigma Software
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
Praveen M Jigajinni
 
Tutorial2
Tutorial2Tutorial2
Tutorial2
ashumairitar
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
PyCon Italia
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
rik0
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
Arockia Abins
 
Subtle Asynchrony by Jeff Hammond
Subtle Asynchrony by Jeff HammondSubtle Asynchrony by Jeff Hammond
Subtle Asynchrony by Jeff Hammond
Patrick Diehl
 
ForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptxForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptx
AaliyanShaikh
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1 Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
To Sum It Up
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
Mohamed Yaser
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
Johan Tibell
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
Devnology
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
SALU18
 
Столпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойСтолпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай Мозговой
Sigma Software
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
rik0
 
Subtle Asynchrony by Jeff Hammond
Subtle Asynchrony by Jeff HammondSubtle Asynchrony by Jeff Hammond
Subtle Asynchrony by Jeff Hammond
Patrick Diehl
 
ForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptxForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptx
AaliyanShaikh
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1 Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
To Sum It Up
 
Ad

More from pramodkumar1804 (20)

Matlab syntax
Matlab syntaxMatlab syntax
Matlab syntax
pramodkumar1804
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
pramodkumar1804
 
Matlab simulink
Matlab simulinkMatlab simulink
Matlab simulink
pramodkumar1804
 
Matlab polynomials
Matlab polynomialsMatlab polynomials
Matlab polynomials
pramodkumar1804
 
Matlab overview 3
Matlab overview 3Matlab overview 3
Matlab overview 3
pramodkumar1804
 
Matlab overview 2
Matlab overview 2Matlab overview 2
Matlab overview 2
pramodkumar1804
 
Matlab overview
Matlab overviewMatlab overview
Matlab overview
pramodkumar1804
 
Matlab operators
Matlab operatorsMatlab operators
Matlab operators
pramodkumar1804
 
Matlab variables
Matlab variablesMatlab variables
Matlab variables
pramodkumar1804
 
Matlab numbers
Matlab numbersMatlab numbers
Matlab numbers
pramodkumar1804
 
Matlab matrics
Matlab matricsMatlab matrics
Matlab matrics
pramodkumar1804
 
Matlab m files
Matlab m filesMatlab m files
Matlab m files
pramodkumar1804
 
Matlab loops 2
Matlab loops 2Matlab loops 2
Matlab loops 2
pramodkumar1804
 
Matlab loops
Matlab loopsMatlab loops
Matlab loops
pramodkumar1804
 
Matlab graphics
Matlab graphicsMatlab graphics
Matlab graphics
pramodkumar1804
 
Matlab gnu octave
Matlab gnu octaveMatlab gnu octave
Matlab gnu octave
pramodkumar1804
 
Matlab operators
Matlab operatorsMatlab operators
Matlab operators
pramodkumar1804
 
Matlab decisions
Matlab decisionsMatlab decisions
Matlab decisions
pramodkumar1804
 
Matlab data import
Matlab data importMatlab data import
Matlab data import
pramodkumar1804
 
Matlab colon notation
Matlab colon notationMatlab colon notation
Matlab colon notation
pramodkumar1804
 
Ad

Recently uploaded (20)

pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
National Information Standards Organization (NISO)
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 

Matlab integration

  • 1. http://www.tutorialspoint.com/matlab/matlab_integ ration.htm Copyright © tutorialspoint.com MATLAB - INTEGRATION Integrationdeals withtwo essentially different types of problems. Inthe first type, derivative of a functionis givenand we want to find the function. Therefore, we basically reverse the process of differentiation. This reverse process is knownas anti-differentiation, or finding the primitive function, or finding anindefinite integral. The second type of problems involve adding up a very large number of very smallquantities and then taking a limit as the size of the quantities approaches zero, while the number of terms tend to infinity. This process leads to the definitionof the definite integral. Definite integrals are used for finding area, volume, center of gravity, moment of inertia, work done by a force, and innumerous other applications. Finding Indefinite Integral Using MATLAB By definition, if the derivative of a functionf(x) is f'(x), thenwe say that anindefinite integralof f'(x) withrespect to x is f(x). For example, since the derivative (withrespect to x) of x2 is 2x, we cansay that anindefinite integralof 2x is x2. Insymbols: f'(x2) = 2x, therefore, ∫ 2xdx = x2. Indefinite integralis not unique, because derivative of x2 + c, for any value of a constant c, willalso be 2x. This is expressed insymbols as: ∫ 2xdx = x2 + c. Where, c is called an'arbitrary constant'. MATLAB provides anint command for calculating integralof anexpression. To derive anexpressionfor the indefinite integralof a function, we write: int(f); For example, fromour previous example: syms x int(2*x) MATLAB executes the above statement and returns the following result: ans = x^2 Example 1 Inthis example, let us find the integralof some commonly used expressions. Create a script file and type the following code init: syms x n int(sym(x^n)) f = 'sin(n*t)' int(sym(f)) syms a t
  • 2. int(a*cos(pi*t)) int(a^x) Whenyourunthe file, it displays the following result: ans = piecewise([n == -1, log(x)], [n ~= -1, x^(n + 1)/(n + 1)]) f = sin(n*t) ans = -cos(n*t)/n ans = (a*sin(pi*t))/pi ans = a^x/log(a) Example 2 Create a script file and type the following code init: syms x n int(cos(x)) int(exp(x)) int(log(x)) int(x^-1) int(x^5*cos(5*x)) pretty(int(x^5*cos(5*x))) int(x^-5) int(sec(x)^2) pretty(int(1 - 10*x + 9 * x^2)) int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2) pretty(int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2)) Note that the pretty command returns anexpressionina more readable format. Whenyourunthe file, it displays the following result: ans = sin(x) ans = exp(x) ans = x*(log(x) - 1) ans = log(x) ans = (24*cos(5*x))/3125 + (24*x*sin(5*x))/625 - (12*x^2*cos(5*x))/125 + (x^4*cos(5*x))/5 - (4*x^3*sin(5*x))/25 + (x^5*sin(5*x))/5 2 4 24 cos(5 x) 24 x sin(5 x) 12 x cos(5 x) x cos(5 x) ----------- + ------------- - -------------- + ----------- - 3125 625 125 5 3 5
  • 3. 4 x sin(5 x) x sin(5 x) ------------- + ----------- 25 5 ans = -1/(4*x^4) ans = tan(x) 2 x (3 x - 5 x + 1) ans = - (7*x^6)/12 - (3*x^5)/5 + (5*x^4)/8 + x^3/2 6 5 4 3 7 x 3 x 5 x x - ---- - ---- + ---- + -- 12 5 8 2 Finding Definite Integral Using MATLAB By definition, definite integralis basically the limit of a sum. We use definite integrals to find areas suchas the area betweena curve and the x-axis and the area betweentwo curves. Definite integrals canalso be used inother situations, where the quantity required canbe expressed as the limit of a sum. The int command canbe used for definite integrationby passing the limits over whichyouwant to calculate the integral. To calculate we write, int(x, a, b) For example, to calculate the value of we write: int(x, 4, 9) MATLAB executes the above statement and returns the following result: ans = 65/2 Following is Octave equivalent of the above calculation: pkg load symbolic symbols x = sym("x");
  • 4. f = x; c = [1, 0]; integral = polyint(c); a = polyval(integral, 9) - polyval(integral, 4); display('Area: '), disp(double(a)); Analternative solutioncanbe givenusing quad() functionprovided by Octave as follows: pkg load symbolic symbols f = inline("x"); [a, ierror, nfneval] = quad(f, 4, 9); display('Area: '), disp(double(a)); Example 1 Let us calculate the area enclosed betweenthe x-axis, and the curve y = x3−2x+5 and the ordinates x = 1 and x = 2. The required area is givenby: Create a script file and type the following code: f = x^3 - 2*x +5; a = int(f, 1, 2) display('Area: '), disp(double(a)); Whenyourunthe file, it displays the following result: a = 23/4 Area: 5.7500 Following is Octave equivalent of the above calculation: pkg load symbolic symbols x = sym("x"); f = x^3 - 2*x +5; c = [1, 0, -2, 5]; integral = polyint(c); a = polyval(integral, 2) - polyval(integral, 1); display('Area: '), disp(double(a)); Analternative solutioncanbe givenusing quad() functionprovided by Octave as follows: pkg load symbolic symbols
  • 5. x = sym("x"); f = inline("x^3 - 2*x +5"); [a, ierror, nfneval] = quad(f, 1, 2); display('Area: '), disp(double(a)); Example 2 Find the area under the curve: f(x) = x2 cos(x) for −4 ≤ x ≤ 9. Create a script file and write the following code: f = x^2*cos(x); ezplot(f, [-4,9]) a = int(f, -4, 9) disp('Area: '), disp(double(a)); Whenyourunthe file, MATLAB plots the graph: and displays the following result: a = 8*cos(4) + 18*cos(9) + 14*sin(4) + 79*sin(9) Area: 0.3326 Following is Octave equivalent of the above calculation: pkg load symbolic symbols x = sym("x"); f = inline("x^2*cos(x)"); ezplot(f, [-4,9]) print -deps graph.eps [a, ierror, nfneval] = quad(f, -4, 9);