軸上でマウスをクリッ​クし、座標点を表示さ​せるにはどうすればよ​いですか?

8 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 25 de Oct. de 2013
Respondida: MathWorks Support Team el 25 de Oct. de 2013
GUIDE で作成した Figure において、軸上でマウスをクリックし、座標点を表示させる方法を教えてください。

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 25 de Oct. de 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行目は、背面の座標面に対する位置を示します。

Más respuestas (0)

Productos


Versión

R2009a

Community Treasure Hunt

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

Start Hunting!