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.

采纳的回答

Simon Chan
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 CenterFile Exchange 中查找有关 Robotics 的更多信息

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by