Borrar filtros
Borrar filtros

Animating a circle based on diameter data

1 visualización (últimos 30 días)
Kelly McGuire
Kelly McGuire el 26 de Abr. de 2018
Editada: Ameer Hamza el 27 de Abr. de 2018
I have two columns of data. In one is the frame number (which I may convert to time in nanoseconds) and in the other is the diameter of an object at that frame or time. I would like to create an animated circle, where the circle is animated based on the changing diameter. For example, at frame 0 the diameter is 10 nanometers, at frame 1 the diameter is 9.5 nanometers, at frame 2 the diameter is 9 nanometers, and so on for about 4,000 frames. I would like to create a circle that is animated, changing by those diameters per frame. Can someone help with this? Thanks!

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 26 de Abr. de 2018
Editada: Ameer Hamza el 27 de Abr. de 2018
Here is a general sketch to create such animation. This code will write the animation frames to a video, you can modify the code according to your requirement.
animationWriter = VideoWriter('animation_file');
open(animationWriter);
for i=1:4000
% create data for circle plot or any other processing you want to do
f = ....; % write your plotting command here using plot() or any other graphics primitive
frame = getframe(gcf);
writeVideo(animationWriter, frame);
end
close(animationWriter);
  3 comentarios
Kelly McGuire
Kelly McGuire el 27 de Abr. de 2018
Thanks for the help! Couple of questions. 1) Is 'animation_file' the name I want to give my file and without quotes? 2) How does the i=4000 know to use a column of data points? 3) Forgive my novice status, but how would the f = ... part know to use the data points in my column as the diameter of the circle? Thanks!
Ameer Hamza
Ameer Hamza el 27 de Abr. de 2018
1) You will need to input file name in quotes e.g. 'myFile'.
2) I put ... in my code for you to fill. You can write your own code there. You can plot whatever you want there and it will create an animation based on plots you create.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by