MathJax TeX Test Page Following is a simple pendulum in Cartesian coordinate system: \begin{align*} 0 = f_1 &= x'' + x\lambda\\[1ex] 0 = f_2 &= y'' + y\lambda - G \\[1ex] 0 = f_3 &= x^2 + y^2 - L^2 \end{align*} Here $x(t), y(t), \lambda(t)$ are state variables. $G$ is gravity, and $L>0$ is the length of the pendulum.

Specifying a DAE in a Matlab function










To translate this DAE into a Matlab function, we create a file pend.m and encode


​function f = pend(t, z, G, L)

x = z(1); y = z(2); lam = z(3);


f(1) = Dif(x,2) + x*lam;

f(2) = Dif(y,2) + y*lam - G;

f(3) = x^2 + y^2 - L^2;






© Gary Guangning Tan, 2015