App designerでグ​ラフクリックをトリガ​ーにしたい

조회 수: 5 (최근 30일)
qrqr
qrqr 2020년 1월 22일
답변: Etsuo Maeda 2020년 1월 31일
MATLAB2018bのApp designerを使い以下のようなGUIを作成しました。
この時、グラフの各データをクリックすると座標が自動で表示されますが、このクリックを起点に関数を実行することはできるのでしょうか?
また、クリックしたときの表示されてる座標を変数に格納することもできますか?
宜しくお願いします。

채택된 답변

Musashi Ito
Musashi Ito 2020년 1월 28일
편집: Musashi Ito 2020년 1월 28일
ご参考までに、はっきりした回答ではないのですが、グラフの各データをクリックすると座標が自動で表示される機能は「データ ヒント」と呼ぶらしいです。表示をカスタマイズもできそうです。
このデータ ヒントから座標値も datacursormode 関数で取得できるみたいです。
が、App Designer 上のグラフをクリックして座標値を取得して変数に格納、となると難しいかもしれません・・・
  댓글 수: 1
qrqr
qrqr 2020년 1월 28일
ありがとうございます。
クリック時の関数を定義すると(WindowButtonUp、Down)、
データヒントの表示がなくなります。
datacursormode on の設定をしてるのですが表示されません。
何が原因なのでしょうか??

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Etsuo Maeda
Etsuo Maeda 2020년 1월 31일
x = rand(10, 2);
scatter(x(:, 1), x(:, 2))
do = datacursormode(gcf);
do.UpdateFcn = @myFun;
function output_txt = myFun(~, event)
pos = get(event, 'Position');
output_txt = {['X: ', num2str(pos(1))], ['Y: ', num2str(pos(2))]};
disp(pos)
end
HTH

카테고리

Help CenterFile Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!