フィルターのクリア

How to graph current Pointer Location

3 ビュー (過去 30 日間)
Matthew
Matthew 2014 年 11 月 21 日
編集済み: Adam 2014 年 11 月 21 日
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
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
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 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by