*Enlace a Spanish version
Materials: [ Cód.: TankAnimInteractive.zip ] [ PDF ]
This video details the Matlab code for interactive animation (responding to
keyboard input) of filling or emptying a liquid storage tank. This animation was
used in previously piublished introductory motivational videos for systems
engineering ([
Here we discuss line by line the class (classdef) that handles the animation data and has the following methods:
constructor, to initialize the data;
“frame” drawing for animation, 20 times per second;
simulation of the differential equation , approximating by Euler’s method. If the sampling period (frame to frame, 1/20 s) were larger, another numerical integration method might be needed, such as ode45. This method is the most conceptually important from a systems theory point of view (numerical integration).
Response to ‘key press’ event to perform different actions depending on the key that the user had actually pressed. The actions are raising/lowering inlet flow or stopping the simulation.
Last, the code of a script that is in charge of creating the animation, simulating for a certain time and presenting input and output plots once the simulation is finished is, too, detailed.
*Link to my [ whole collection] of videos in English. Link to larger [ Colección completa] in Spanish.