handle mouse in figure with matlab
1 次查看(过去 30 天)
显示 更早的评论
hi,I want to select any closed curve in a figure displayed by Matlab and automatically apply an algorithm, that is to say, the call of this algorithm is done automatically after the selection of this zone in closed curve. while waiting for a friendly answer, that you find here my best regards.
0 个评论
回答(1 个)
Greg
2017-11-2
编辑:Greg
2017-11-2
Set the ButtonDownFcn of the plotted object to the algorithm you want to apply. The last line of the algorithm can be to set the callback to empty string so that it only runs the algorithm once, if that is desired behavior.
plot(1:10,'ButtonDownFcn',@myalgorithm);
This will apply to the whole curve, not specific segments of a single curve. Your question was a little ambiguous which way you needed.
3 个评论
Greg
2017-11-6
It could be my ignorance (which I apologize for) of the terminology you're using that is making the question ambiguous to me.
For example (and let's assume a plot of 1:10 counts as a closed curve, even if it doesn't): Are you looking for an algorithm to run if the user clicks anywhere in say 1:3, and a DIFFERENT algorithm to run if the user clicks 4:8? Or should one single algorithm run no matter where the user clicks on the line 1:10?
In the first case, you'd need a logic wrapper as the callback that determines which algorithm to run. In the second case, the algorithm could directly be the callback.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!