필터 지우기
필터 지우기

How to create multiple interactive points using "impoint" in an array and get the position of the one I clicked on?

조회 수: 2 (최근 30일)
I'm currently trying to generate n interactive points linked by a function using impoint and saving them in an array to extend the number of points if I want to. This was a topic before and a solution proposed by Giovanni Ughi doesn't work if I use the addNewPositionCallback like below (here as comment, you can remove % to try it):
[dim_y dim_x] = size(array); k = 0; for i = 10:10:dim_y % for example creating one every 10
k = k+1;
genio(k).h = impoint(gca,array(i,2),array(i,1));
% addNewPositionCallback(genio(k).h,@(genio(k).h) title(sprintf('(%1.0f,%1.0f)',genio(k).h(1),genio(k).h(2))));
% Construct boundary constraint function
fcn = makeConstrainToRectFcn('impoint',get(gca,'XLim'),get(gca,'YLim'));
% Enforce boundary constraint function using setPositionConstraintFcn
setPositionConstraintFcn(genio(k).h,fcn);
setColor(genio(k).h,'y');
end
If someone has solved that problem for a variable number of impoints I would be really grateful. Common solutions use Globals and are using copies for every impoint. Any suggestions?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Build Interactive Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by