How to overlap 2 graph on a single figure, one of them is a dynamic, changing in each step?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Akash Vyas
am 13 Mär. 2022
Kommentiert: Akash Vyas
am 13 Mär. 2022

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 Kommentar
KSSV
am 13 Mär. 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?
Akzeptierte Antwort
Simon Chan
am 13 Mär. 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
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!