Animating a circle based on diameter data

1 view (last 30 days)
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!

Accepted Answer

Ameer Hamza
Ameer Hamza on 26 Apr 2018
Edited: Ameer Hamza on 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 Comments
Kelly McGuire
Kelly McGuire on 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 on 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!