The following Matlab project contains the source code and Matlab examples used for a spring-damper teaching aid . It's been used in undergraduate teaching for a few years. It's a single file - start it by running 'dynamics'. There's a help button leading to some documentation.
The source code and files included in this project are listed in the project files section, please make sure whether the listed source code meet your needs there.