I have created circles by the help of fill command. how can I make them movingly linearly.
fill(xobs(k)+robs(k)*cos(theta),yobs(k)+robs(k)*sin(theta),[1 0 0]);
They can be moving in circular motion.

 채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 1일

0 개 추천

You can record the handles returned by fill(), which will be handles of patch objects. The patch objects that are created will have a Vertices property which will be an N x 2 array. You can change the Vertices property to update the locations, such as
rot = makehgtform('zrotate', 15*180/pi);
V = h.Vertices;
temp = [V,zeros(size(V,1),2)] * rot;
h.Vertices = temp(:,1:2);

댓글 수: 6

xobs=[1.5 4.0 1.2 7.0 8.0];
yobs=[4.5 3.0 1.5 5.0 8.0];
robs=[1.5 1.0 0.8 1.0 1.0];
theta=linspace(0,2*pi,100);
for k=1:numel(xobs)
fill(xobs(k)+robs(k)*cos(theta),yobs(k)+robs(k)*sin(theta),[1 1 0]);
end
This is code I need these circles to be moving linearly
xobs=[1.5 4.0 1.2 7.0 8.0];
yobs=[4.5 3.0 1.5 5.0 8.0];
robs=[1.5 1.0 0.8 1.0 1.0];
theta=linspace(0,2*pi,100);
for k=1:numel(xobs)
fh(k) = fill(xobs(k)+robs(k)*cos(theta),yobs(k)+robs(k)*sin(theta),[1 1 0]);
xspeed(k) = randn()/2;
yspeed(k) = randn()/2;
end
for iterations = 1 : 100
for k = 1 : length(fh)
fh(k).Vertices = fh(k).Vertices + [xspeed(k), yspeed(k)];
end
drawnow();
end
The code assumes R2016b or later.
passioncoding
passioncoding 2019년 5월 3일
the code does not know what vertices are. and it does make acircle but not moving circles.
Put a
hold on
before the code here, and
hold off
after the "for k" loop.
passioncoding
passioncoding 2019년 5월 4일
the code doesnot recognize 'Vertices' it says Invalid or deleted object. Plus there is no motion in circles. only a single circle is plot
Walter Roberson
Walter Roberson 2019년 5월 4일
Code enclosed to prove that it does work. Also enclosed is a movie with proof that it works.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Networks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by