MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of
5 Differential Equations 2.5 Solution of van der Pol Equation, µ = 1000 2 1.5 1 0.5 solution y 1 0 −0.5 −1 −1.5 −2 −2.5 0 500 1000 1500 2000 2500 3000 time t Example: Finite Element Discretization fem1ode illustrates the solution of ODEs that result from a finite element discretization of a partial differential equation. The value of N in the call fem1ode(N) controls the discretization, and the resulting system consists of N equations. By default, N is 19. This example involves a mass matrix. The system of ODEs comes from a method of lines solution of the partial differential equation e – t ∂ ----- u = ∂t ∂ 2 --------- u ∂x 2 with initial condition u( 0, x) = sin( x) and boundary conditions ut0 ( , ) = utπ ( , ) = 0 . An integer N is chosen, h is defined as π ⁄ ( N + 1) , and 5-22
Initial Value Problems for ODEs and DAEs the solution of the partial differential equation is approximated at x k k = 0, 1, ..., N+1 by = kh for N ∑ utx (, k ) ≈ c k ()φ t k ( x) k = 1 Here φ k () x is a piecewise linear function that is 1 at x k and 0 at all the other . A Galerkin discretization leads to the system of ODEs x j Mt ()c′ = Jc where ct () = c 1 () t c N () t and the tridiagonal matrices Mt () and J are given by and ⎧2h ⁄ 3exp( – t) if i = j ⎪ M ij = ⎨h ⁄ 6exp( – t) if i = j ± 1 ⎪ ⎩ 0 otherwise ⎧ – 2 ⁄ h if i = j ⎪ J ij = ⎨ 1 ⁄ h if i = j ± 1 ⎪ ⎩ 0 otherwise The initial values c( 0) are taken from the initial condition for the partial differential equation. The problem is solved on the time interval [ 0, π] . In the fem1ode example, the properties options = odeset('Mass',@mass,'MStateDep','none','Jacobian',J) indicate that the problem is of the form Mt ()y′ = Jy . The nested function mass(t) evaluates the time-dependent mass matrix Mt () and J is the constant Jacobian. 5-23
- Page 106 and 107: 4 Function Functions You can also c
- Page 108 and 109: 4 Function Functions 25 20 15 10 5
- Page 110 and 111: 4 Function Functions Minimizing Fun
- Page 112 and 113: 4 Function Functions To try fminsea
- Page 114 and 115: 4 Function Functions Plotting the R
- Page 116 and 117: 4 Function Functions The number of
- Page 118 and 119: 4 Function Functions and displays t
- Page 120 and 121: 4 Function Functions end function s
- Page 122 and 123: 4 Function Functions States of the
- Page 124 and 125: 4 Function Functions 100 80 60 40 2
- Page 126 and 127: 4 Function Functions You can verify
- Page 128 and 129: 4 Function Functions Troubleshootin
- Page 130 and 131: 4 Function Functions A three-dimens
- Page 132 and 133: 4 Function Functions Parameterizing
- Page 134 and 135: 4 Function Functions “Anonymous F
- Page 136 and 137: 5 Differential Equations Initial Va
- Page 138 and 139: 5 Differential Equations odephas3 o
- Page 140 and 141: 5 Differential Equations This secti
- Page 142 and 143: 5 Differential Equations The basic
- Page 144 and 145: 5 Differential Equations 2 Code the
- Page 146 and 147: 5 Differential Equations function.
- Page 148 and 149: 5 Differential Equations One way to
- Page 150 and 151: 5 Differential Equations y0, yp0 Ve
- Page 152 and 153: 5 Differential Equations For exampl
- Page 154 and 155: 5 Differential Equations 1 0.8 0.6
- Page 158 and 159: 5 Differential Equations To run thi
- Page 160 and 161: 5 Differential Equations 2 u′ i =
- Page 162 and 163: 5 Differential Equations dydt(i+1,:
- Page 164 and 165: 5 Differential Equations refine = 4
- Page 166 and 167: 5 Differential Equations Example: A
- Page 168 and 169: 5 Differential Equations function [
- Page 170 and 171: 5 Differential Equations Note The R
- Page 172 and 173: 5 Differential Equations 1 Robertso
- Page 174 and 175: 5 Differential Equations The MATLAB
- Page 176 and 177: 5 Differential Equations Summary of
- Page 178 and 179: 5 Differential Equations Problem Si
- Page 180 and 181: 5 Differential Equations Error Tole
- Page 182 and 183: 5 Differential Equations Troublesho
- Page 184 and 185: 5 Differential Equations Function d
- Page 186 and 187: 5 Differential Equations dde23 prod
- Page 188 and 189: 5 Differential Equations The exampl
- Page 190 and 191: 5 Differential Equations solution y
- Page 192 and 193: 5 Differential Equations Example: C
- Page 194 and 195: 5 Differential Equations Changing D
- Page 196 and 197: 5 Differential Equations BVP Functi
- Page 198 and 199: 5 Differential Equations two-point
- Page 200 and 201: 5 Differential Equations The input
- Page 202 and 203: 5 Differential Equations 2 Pass the
- Page 204 and 205: 5 Differential Equations 3 Code the
Initial Value Problems for ODEs and DAEs<br />
the solution <strong>of</strong> the partial differential equation is approximated at x k<br />
k = 0, 1, ..., N+1 by<br />
=<br />
kh<br />
for<br />
N<br />
∑<br />
utx (, k ) ≈ c k ()φ t k ( x)<br />
k = 1<br />
Here φ k () x is a piecewise linear function that is 1 at x k and 0 at all the other<br />
. A Galerkin discretization leads to the system <strong>of</strong> ODEs<br />
x j<br />
Mt ()c′<br />
= Jc where ct () =<br />
c 1 () t<br />
c N () t<br />
and the tridiagonal matrices Mt () and J are given by<br />
and<br />
⎧2h ⁄ 3exp( – t)<br />
if i = j<br />
⎪<br />
M ij = ⎨h ⁄ 6exp( – t)<br />
if i = j ± 1<br />
⎪<br />
⎩ 0 otherwise<br />
⎧ – 2 ⁄ h if i = j<br />
⎪<br />
J ij = ⎨ 1 ⁄ h if i = j ± 1<br />
⎪<br />
⎩ 0 otherwise<br />
The initial values c( 0)<br />
are taken from the initial condition for the partial<br />
differential equation. The problem is solved on the time interval [ 0,<br />
π]<br />
.<br />
In the fem1ode example, the properties<br />
options = odeset('Mass',@mass,'MStateDep','none','Jacobian',J)<br />
indicate that the problem is <strong>of</strong> the form Mt ()y′ = Jy . The nested function<br />
mass(t) evaluates the time-dependent mass matrix Mt () and J is the constant<br />
Jacobian.<br />
5-23