How to save mouse positions with respect to time in MATLAB workspace? I can track continuous mouse movements using assignin func but, I want to save it for a period of time.

5 views (last 30 days)
I am working on building a task, where a person will drag the mouse from one target to another. I want to achieve following objectives:
1) Start and stop recording mouse pointer positions
I used this lines of code that worked appropriately in Matlab environment but, I couldn't run it in MATLAB Appdesigner:
set(gcf,'windowbuttondownfcn', {@startStopMouseMove, WindowButtonMotionFcnInput})
function startStopMouseMove(hobj,~,WindowButtonMotionFcnInput)
% Turns mouse tracking off (right mouse button) and on (left mouse button)
buttonID = hobj.SelectionType;
switch buttonID
case 'normal' %left mouse button
% Start interactivity
set(hobj,'windowbuttonmotionfcn', WindowButtonMotionFcnInput);
case 'alt' % right mouse button
% Stop interactivity
set(hobj,'windowbuttonmotionfcn', []);
end
end
2)Record and save all the mouse positions between each target with respect to time
But, now I would like to save those values in the matlab workspace as a matrix that can be later used for calculations
  1 Comment
Stephen23
Stephen23 on 10 Jan 2022
"But, now I would like to save those values in the matlab workspace as a matrix that can be later used for calculations"
Forcing all of the data into the base workspace is inefficient and complex.
The simple and efficient approach is to processs the data from within the GUI. Is there any particular reason why you cannot process the data from within the GUI? Perhaps this is what you need:

Sign in to comment.

Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!