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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Audio Processing Algorithm Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!