Plot Circle In For Loop
显示 更早的评论
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 个评论
Geoff Hayes
2018-4-27
编辑:Geoff Hayes
2018-4-27
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
2018-4-27
编辑:Kelly McGuire
2018-4-27
Geoff Hayes
2018-4-27
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
2018-4-27
Kelly McGuire
2018-4-27
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Animation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
