How to plot dots?
4 views (last 30 days)
Show older comments
I know there has been asked similar questions, but they did not help me. I am relatively new to Matlab. I have got the following graphs and want to plot dots. The first dot should be at -5,10m, that is the following equation:
x10 = 1/2 * dx10^2/g; % distance x at v=-10m/s
The second dot should be at dx = -10m/s How can I add these fixed dots to my graph? And is it possible to stop the animation of the moving dots, when they reached dx = -10 m/s?
My complete code is attached. :-)
0 Comments
Answers (1)
madhan ravi
on 24 Oct 2018
Edited: madhan ravi
on 24 Oct 2018
i=1;
'on'
while dxBall(i) >= -10
% update point & text for ball 1
plot(tball(i),xBall(i),'o')
hold on
set(hLine1, 'XData', tball(i), 'YData',xBall(i))
set(hTxt1, 'Position', [tball(i) xBall(i)], ...
'String', sprintf('%.3f,%3f)',[tball(i) xBall(i)]))
% ... and the same for ball 2
set(hLine2, 'XData', tball(i), 'YData',dxBall(i))
set(hTxt2, 'Position', [tball(i) dxBall(i)], ...
'String', sprintf('%.3f,%3f)',[tball(i) dxBall(i)]))
drawnow % force refresh
pause(DELAY) % slow down animation
i = rem(i+1,length(tball))+1; % circular increment
if ~ishandle(hLine1), break; end % in case you close the figure
end
'off'
See Also
Categories
Find more on Animation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!