How to plot dots?
조회 수: 6 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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'
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!