How to graph current Pointer Location
조회 수: 5 (최근 30일)
이전 댓글 표시
For a current project I am trying to graph a current representation of the pointer from my computer. I know how to get the current pointer location using:
>>get(0,'PointerLocation') ans = x-coordinate y-coordinate
I know that I need to create a loop in order to do this. What would I need to write as a script in order to graph the current pointer location? I've seen an example and the graph's point should move about the graph's parameters just as the pointer would move about the computer monitor's parameters.
Any advice would be beneficial! Matthew
댓글 수: 1
matt dash
2014년 11월 21일
Not clear if you want the pointer moving over a matlab figure and it leaves a trail behind it, like you're drawing, or if the pointer is moving over non-matlab windows and its trail is being plotted in a separate window. This will change the implementation.
채택된 답변
Adam
2014년 11월 21일
편집: Adam
2014년 11월 21일
Something like the following would work, although this is an infinite loop. I haven't put any thought into how you would terminate it - I had to use Ctrl C
figure; hold on
while(1)
xy = get(0,'PointerLocation');
plot( xy(1), xy(2), 'Marker', '+' )
drawnow
pause( 0.1)
end
Obviously that is just a guide, you can set your own marker type, colour, type of plot etc.
To have the plot so that it literally follows the mouse would be trickier - you would have to preset the axis limits to match your screen size, allowing for the frame around the axes, etc.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!