
軸上でマウスをクリックし、座標点を表示させるにはどうすればよいですか?
7 views (last 30 days)
Show older comments
MathWorks Support Team
on 25 Oct 2013
Answered: MathWorks Support Team
on 25 Oct 2013
GUIDE で作成した Figure において、軸上でマウスをクリックし、座標点を表示させる方法を教えてください。
Accepted Answer
MathWorks Support Team
on 25 Oct 2013
Figure の WindowButtonDownFcnコールバックに下記を定義します。
Axes の 'CurrentPoint' プロパティでは、Axes の単位に基づいたカレントのマウス位置を取得することができます。
これにより、クリックした点を取得することが可能です。
% handles.axes1: Axesのハンドル
pos = get(handles.axes1,'CurrentPoint')
pos(1,1) % x座標
pos(1,2) % y座標
なお、'CurrentPoint' で得られる行列は、次の要素を含みます。
pos =
[ xfront, yfront, zfront;
xback, yback,zback]
2次元座標の場合、行列の 1 行目、2行目の値は一致しますが、3 次元の座標軸の場合、行列の 1 行目は、前面の座標面に対する位置、2行目は、背面の座標面に対する位置を示します。

0 Comments
More Answers (0)
Categories
Find more on アニメーション 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!