How to overlap 2 graph on a single figure, one of them is a dynamic, changing in each step?
1 回表示 (過去 30 日間)
古いコメントを表示
I've plotted the C-space representation of a RR-manipulator, and there are two obstical (Red, green) in C-space, Now I wanted to move the current configuration (black dot) in the C-space but I don't know how to animate the movement of black dot in this still image.
1 件のコメント
KSSV
2022 年 3 月 13 日
Do you have the (x,y) coordinates for the red and green arrows shown? Where you want to move the block dot? To red or green?
採用された回答
Simon Chan
2022 年 3 月 13 日
Update the black dot position in the for loop as follows:
f = figure;
ax = gca;
x1 = xline(ax,6); % Simulate the red obstacle
hold(ax,'on');
x2 = xline(ax,20); % Simulate the green obstacle
xlim(ax,[1 25]);
ylim(ax,[0 100]);
Npoint = 100; % Movement of black dot (say 100 positions)
RRx = randi([7 19],1,Npoint); % Dummy data for x-coordinates of black dot
RRy = randi([1 99],1,Npoint); % Dummy data for y-coorindtaes of black dot
h = plot(ax,RRx(1),RRy(1),'b*','MarkerSize',10); % Plot the first black dot
pause(0.2);
for k = 2:Npoint
h.XData = RRx(k); % Update the x-coordinates of black dot
h.YData = RRy(k); % Update the y-coordinates of black dot
pause(0.2); % Pause 0.2sec for each update, to avoid refresh too fast
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Robotics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!