Plot Circle In For Loop
Mostra commenti meno recenti
I have this code that is set up to animate a circle plot based on the circle's diameter. I am struggling with how to plot the circle based on the diameter in the for loop. I have one column vector of 1,667 columns. In each of those columns is the diameter (i.e. 1,667 diameters from data). I want to animate the circle changing based on those diameters. So, I need the plot in the for loop to go through, iterate through the columns, and update the plot, and but show that as an animation. I've attached my code. Please help with the plot portion of the code, thanks!
5 Commenti
Geoff Hayes
il 27 Apr 2018
Modificato: Geoff Hayes
il 27 Apr 2018
Kelly - your code is simply
animationWriter = VideoWriter('HSPtoHSPCircle');
open(animationWriter);
[a,b] = size(B);
for i = 1:a
for j = 1:b
% create data for circle plot or any other
% processing you want to do
f = ....; % plot your circle here using plot() or any other graphics primitive
frame = getframe(f);
videoWriter(animationWriter, frame);
end
end
close(animationWriter);
Is B your 1667x1 array of diameters? If so, why do you loop over the rows and columns of B? Or is B a matrix?
I would start with https://www.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center which describes how to draw a circle given its (x,y) coordinates and radius.
The code you are using is that which was given to you at https://www.mathworks.com/matlabcentral/answers/397442-animating-a-circle-based-on-diameter-data. Why haven't you tried to do something with this code instead of posing a new question?
Kelly McGuire
il 27 Apr 2018
Modificato: Kelly McGuire
il 27 Apr 2018
Geoff Hayes
il 27 Apr 2018
And this https://www.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center doesn't do what you want for one circle?
Kelly McGuire
il 27 Apr 2018
Kelly McGuire
il 27 Apr 2018
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Animation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
