how to make different points movable in MATLAB

조회 수: 2 (최근 30일)
passioncoding
passioncoding 2019년 2월 2일
편집: Walter Roberson 2019년 2월 6일
I wanted help in making different point moving with constant velocity. All points should be moving at constant speed.

채택된 답변

Walter Roberson
Walter Roberson 2019년 2월 2일
Use scatter and record the handle . Loop updating the XData and YData properties of the handle and drawnow()
  댓글 수: 6
passioncoding
passioncoding 2019년 2월 6일
Since I want to make the points moving with constant velocity, Vobs can be fixed number. Secondly yes its a theta, direction for particels/point to move forward.
Walter Roberson
Walter Roberson 2019년 2월 6일
편집: Walter Roberson 2019년 2월 6일
%need _some_ Vobs and theta
theta = rand() * 2 * pi;
Vobs = rand() * 10;
h=msgbox('Select Obstacles using the Left Mouse button,to select the last obstacle use the Right button');
xlabel('Select Obstacles using the Left Mouse button,to select the last obstacle use the Right button','Color','blue');
uiwait(h,10);
if ishandle(h) == 1
delete(h);
end
count = 0;
xvals = []; yvals = [];
while true
[xval,yval,but] = ginput(1);
if isempty(xval); break; end
count = count + 1;
xvals(count) = floor(xval);
yvals(count) = floor(yval);
end
dx = Vobs * cos(theta);
dy = Vobs * sin(theta);
pointsize = 10;
h = scatter(xvals, yvals, pointsize, 'r');
for step = 1 : 100
xvals = xvals + dx;
yvals = yvals + dy;
set(h, 'XData', xvals, 'YData', yvals);
drawnow();
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by