How to plot dots?

4 ビュー (過去 30 日間)
Christine Hümmer
Christine Hümmer 2018 年 10 月 24 日
編集済み: madhan ravi 2018 年 10 月 24 日
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. :-)

回答 (1 件)

madhan ravi
madhan ravi 2018 年 10 月 24 日
編集済み: madhan ravi 2018 年 10 月 24 日
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'
  1 件のコメント
madhan ravi
madhan ravi 2018 年 10 月 24 日
just add this part at the end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by