How to overlap 2 graph on a single figure, one of them is a dynamic, changing in each step?

2 visualizaciones (últimos 30 días)
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 comentario
KSSV
KSSV el 13 de Mzo. de 2022
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?

Iniciar sesión para comentar.

Respuesta aceptada

Simon Chan
Simon Chan el 13 de Mzo. de 2022
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

Más respuestas (0)

Categorías

Más información sobre Simulation en Help Center y File Exchange.

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by