Code covered by the BSD License  

Highlights from
Numerical Computing with Simulink, Vol. 1

image thumbnail
from Numerical Computing with Simulink, Vol. 1 by Richard Gran
This sequel to Numerical Computing with MATLAB explores the mathematics of simulation.

LMswitchtime.m
syms Ton t alph th thdot th0 thd0

thdot = solve('th = thdot^2/(2*alph)',thdot) 
thdot = thdot(2)  % Select positive square root
intsect = subs('th = th0 +(-thdot^2+thd0^2)/(2*alph)',thdot)
thdot = solve(intsect,'thdot')
Ton = (thdot-thd0)/alph
pretty(Ton)

Contact us at files@mathworks.com