Simple Animation for N vehicles

This simulates and animates multiple 2D kinematic vehicle models in Simulink
Updated 25 Apr 2018

View License

This is the Readme file for a simple 2D kinematic vehicle animation for N separate vehicles implemented in Matlab's Simulink. There are no special libraries or additional toolboxes required.
The simulink model simulates and displays N vehicles at each timestep. This version was based on the single vehicle version located here:

Software Versions Tested:
This model was developed and tested using Matlab R2014, R2015, R2016b and should work with most other versions. The animation s-function is a modified version of the level 1 m-file s-function from the Mathworks example provided in sanim.m.

Writing .jpeg animation frames to disk at each animation interval slows the simulation considerably. Set animation frames per second, anim_fps, in setup.m and re-run setup.m. Don't forget to turn off your file synchronization services to avoid syncing all the new image files.

Getting started:
Get started by unzipping the .zip file, changing directories to the folder, then running setup.m
at the Matlb command prompt. This will clear the workspace then populate it with the necessary variables to run the Simulink model and associated animation. It will also open the Simulink model file. Press Play or Simulation | Run to execute the Simulink model. The light blue s-function block will bring up the 2D animation figure window and display the steering vehicle at anim_fps frames per second.

Distribution file list:
[00_Readme.mdc.txt] - this file

[setup.m] - run this first, it will bring up the Simulink, then press play to simulate the vehicle

[createAviMovieFromAnimationSequence.m] - auxiliary m-file script for converting a sequence of .jpg images into an Avi using Matlab's VideoWriter() function.

[sanim_XY_vehicle_viz_multi.m] - Simulink m-file s-function that displays N vehicle's of Matlab graphics objects each animation interval, set by anim_fps in setup.m.

[veh_object2.m] - supporting m-file function to create vertices and faces for vehicle and tire graphics objects

[vehicle_animation_sim_multi.jpg] - desktop screenshot showing the Simulink model and animation window

[vehicle_animation_sim_multi.pdf] - printout of the Simulink block diagram in case you cannot open the Simulink

[vehicle_animation_sim_multi.slx] - Matlab/Simulink R2016b model that expressed non-holonomically constrained (rolling) CG velocities and solves for vehicle position as a function of time.

[.\anim_sequences] - folder where animation frame sequence .jpg files are stored; change this in sanim_XY_vehicle_viz_multi.m

[.\Documentation\ folder containing excerpts from lectre notes for ME620 Advanced Vehicle Dynamics

Marc Compere,
created : 11 Jan 2016
modified: 24 Apr 2018

Cite As

Marc Compere (2024). Simple Animation for N vehicles (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Animation in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!


Version Published Release Notes

Minor zip file adjustment
Title change to highlight the N-vehicle animation block
simplifying the readme