Question about impositionrect value updates

1 view (last 30 days)
The code below prints each time the position of the rectangle, but how can i also store that position in a variable?
close all, plot(1:10)
h = impositionrect(gca, [4 4 2 2]);
api = iptgetapi(h);
api.addNewPositionCallback(@(p) disp(p));
Raldi on 15 Jul 2012
No, i didn't mean it like that. I meant sorry for not replying till now.

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 14 Jul 2012
% if you want the latest position u can try this, will save 50 postions for exemple
close all, plot(1:10)
h = impositionrect(gca, [4 4 2 2]);
api = iptgetapi(h)
for k=1:50
n=api.addNewPositionCallback(@(m) disp(m));
position(k,:)= api.getPosition
% this don't allow to save all postion, but allows to save a postion after evry pause (you have to press any key).

More Answers (0)


Find more on Write C Functions Callable from MATLAB (MEX Files) 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!

Translated by