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!
