How to trace the end point of my vector without losing other plots?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have created a short animation using plot where I made a branch of 10 line segments. The branch is waving in the air. I want to only trace the end point without erasing the branch. I tried every posibilities with hold on-off switch. But it traces either the whole thing or erase the branch while tracing the end point. here is my animation. How do I tell matlab that don't specifically erase my end point, while refreshing the plot.
0 Kommentare
Antworten (1)
Jan
am 13 Nov. 2021
Bearbeitet: Jan
am 13 Nov. 2021
Do not delete obejcts and draw new ones, but keep the obejcts and modify the coordinates. If nothing is deleted, it is easy to keep lines in the diagram.
If you post your code, it would be easier to insert the required changes.
axesH = axes('XLim', [0, 100], 'YLim', [0, 100], ...
'NextPlot', 'add'); % As: hold on
pos = [10, 10];
dotH = plot(pos(1), pos(2), 'go', 'Markersize', 20);
for k = 1:100
pause(0.1);
newPos = randi([0, 100], 1, 2);
line([pos(1), newPos(1)], [pos(2), newPos(2)]);
set(dotH, 'XData', newPos(1), 'YData', newPos(2));
pos = newPos;
end
Every object is hold, but the dot is modified. This is even faster than recreaing the object for each frame.
0 Kommentare
Siehe auch
Kategorien
Mehr zu View and Analyze Simulation Results finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!