Filter löschen
Filter löschen

Animating a circle based on diameter data

1 Ansicht (letzte 30 Tage)
Kelly McGuire
Kelly McGuire am 26 Apr. 2018
Bearbeitet: Ameer Hamza am 27 Apr. 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!

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 26 Apr. 2018
Bearbeitet: Ameer Hamza am 27 Apr. 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 Kommentare
Kelly McGuire
Kelly McGuire am 27 Apr. 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 am 27 Apr. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by