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!