Filter löschen
Filter löschen

How to graph current Pointer Location

3 Ansichten (letzte 30 Tage)
Matthew
Matthew am 21 Nov. 2014
Bearbeitet: Adam am 21 Nov. 2014
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 Kommentar
matt dash
matt dash am 21 Nov. 2014
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adam
Adam am 21 Nov. 2014
Bearbeitet: Adam am 21 Nov. 2014
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.

Weitere Antworten (0)

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by