clear ; clc ;
axSize = [500 400];
hFig = uifigure('color', 'white', 'pos', [50 50 axSize ]);
hAxes = uiaxes ('parent', hFig , 'pos', [0 0 axSize ], 'box', 'on', 'XTickLabel', '', 'YTickLabel', '');
hAxes.XLim = [0 1];
hAxes.YLim = [0 1];

tT = timer ;
tT.Period = 0.5;
tT.ExecutionMode = 'fixedRate';
tT.TimerFcn = @(src , event ) timer_update (hAxes , groot );
hFig.CloseRequestFcn = @(a,b) closeReq (hFig ,tT);
drawnow ;
start (tT)
function timer_update (hAx , grt )
pos = grt.PointerLocation ./ grt.ScreenSize (3:4) ;
line (hAx , [pos(1) pos(1) ], [ pos(2) pos(2) ], 'LineStyle', 'none', 'Marker', '.', 'MarkerSize', 20, 'Color', 'r');
end
function closeReq (hFig , tT)
stop (tT);
delete ( hFig );
end
