How to graph current Pointer Location
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
matt dash
le 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.
Réponse acceptée
Adam
le 21 Nov 2014
Modifié(e) : Adam
le 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.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!