animate_fields(dim, varargin)

Watch your time dependant signal play in Matlab with media controls.
266 Downloads
Aktualisiert 3. Dez 2015

Lizenz anzeigen

When working with signals or fields that vary in time, it is often useful to visualize those fields using animations. This function takes 1-dimension or 2-dimension time dependant variables and animates them in Matlab. The user is given media controls and the option to save the animation as a video file for later playback when Matlab isn't available.
animate_fields(dimension,'field name',field) will animate the "field" of a certain "dimension".
For example, the simplest case being a 1D voltage signal:
animate_fields(1,'Voltage',V)
where V is a matrix in which each row represents the voltage across the spatial domain at a certain timestep, i.e. V(:,k) will be the voltage at timestep k.
For 2D fields:
animate_fields(2,'E field',E)
where E(:,:,k) will be the 2D field at timestep k.

Additionally, any number of fields can be animated side by side.

A number of options can be controlled through the function using parameters, such as the ability to manually set the axis sizes, number of frames per second, minimum and maximum amplitudes, grid and colormap.

A more complete example to plot trigonometric functions may look like this:

animate_fields(1,'domain',domain,'grid','on', 'save','file.avi',...
'Sine',sine,...
'Cosine',cosine,...
'Tangent',tangent, 'min_amplitude',-1, 'max_amplitude',1, 'grid','off',...
'Secant',secant, 'min_amplitude',-2, 'max_amplitude',2)

This is my first submission so please feel free to email me with any improvements you might like to share!

Zitieren als

Daniel Simmons (2024). animate_fields(dim, varargin) (https://www.mathworks.com/matlabcentral/fileexchange/46216-animate_fields-dim-varargin), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2013a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Movie finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
2.0.0.0

Fixed bugs that were introduced with Matlab R2014b
Updated to work with Matlab from 2014b

1.0.0.0