NumericalMethods - Lesson 5 - 2021
NumericalMethods - Lesson 5 - 2021
Polytechnic
BBME,BECE,BEEE &BETE
Computer Applications
ELE-COA-411
Lesson 5: Numerical Methods
with MATLAB
RS Bakolo, PhD
2021
Textbook: Introduction to MATLAB for Engineers by W. Palm III
Numerical Integration
2
q=quad('myfunction',0,pi) and
q=quad(@myfunction,0,pi) will both return
the value of 2.0000
To use quad with an unknown function use the
following syntax: choose a function handler, say
Z
Z = @(x)sin(x)
Q = quad(Z,0,pi)
quadl is a more accurate version of quad and it is based
on the adaptive Labatto quadrature rule
>>fun = @(x,y)x.*y^2;
>>A = dblquad(fun,1,3,0,1)
A = triplequad(fun, a, b, c, d, e, f)
computes the triple integral of f(x,y, z) from x = a
to b, y = c to d, and z = e to f. Here is an example
using an anonymous function to represent f(x,y,z)
= (xy -y2)/z.
1 .5
y e x dx
0 .5
4
y e x sin( 3 x ) dx
0
6.6
1
y dx
1
x
Typing
dy
RC
dt
y v(t ) RC 0.1
The DE being if , and
y (0) 2
, for starters we will assume the supply
v(t ) 0
voltage
dy
First, we need a function that evaluatesdt 10 y
dy/dt + 10y = 0
dy/dt = -10y
Next define the following function file. Note that the order of
the input arguments must be t and y.