An electrocardiogram is simulated using an ordinary differential equation. Adjust the parameters of the waves to generate different morphologies.
The model and parameters are adopted from .
 P. E. McSharry, G. D. Clifford, L. Tarassenko, and L. A. Smith, "A Dynamical Model for Generating Synthetic Electrocardiogram Signals," IEEE Transactions on Biomedical Engineering, 50(3), 2003 pp. 289–294. doi:10.1109/TBME.2003.808805. people.maths.ox.ac.uk/mcsharry/papers/ieeetbe50p289.pdf.