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!
