필터 지우기
필터 지우기

アプリケーションデザ​​イナーで、グラ​フ​を消す方法を教​えて​いただけないでし​ょ​うか?(Draw/D​eleteボタンを設​置)

조회 수: 8 (최근 30일)
高木 範明
高木 範明 2023년 10월 16일
댓글: 高木 範明 2023년 10월 16일
アプリケーションデザイナーで、「Draw」ボタンにグラフ作成のコールバックを配置し、「Delete」ボタンでこれを削除するようにコールバックを配置しました。ここで「Draw」ボタンを押してグラフを作成した後、「Delete」ボタンを押してもグラフが消えません。
何が悪いのかご教示いただければ幸いです。
% Button pushed function: DrawButton
function DrawButtonPushed(app, event)
app.ax = app.UIAxes;
  fimplicit(app.UIAxes,@(id,iq) id.^2+iq.^2 - Ia.^2,'BeingDeleted','on');
end
% Button pushed function: DeleteButton
function DeleteButtonPushed(app, event)
app.ax = app.UIAxes;
app.ax.NextPlot='replace';
end
  댓글 수: 1
高木 範明
高木 範明 2023년 10월 16일
転記ミスがありました。訂正いたします。
  fimplicit(app.UIAxes,@(id,iq) id.^2+iq.^2 - Ia.^2,'BeingDeleted','on');
                         ↓
  fimplicit(app.ax,@(id,iq) id.^2+iq.^2 - 10^2,'BeingDeleted','on');

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

채택된 답변

Kojiro Saito
Kojiro Saito 2023년 10월 16일
편집: Kojiro Saito 2023년 10월 16일
グラフの Figure および座標軸の準備が参考になるかもしれません。NextPlotnewplotを実行したときに反映されるので、Deleteボタンのコールバックに1行追加すればプロットが消去されます。
% Button pushed function: DeleteButton
function DeleteButtonPushed(app, event)
app.ax = app.UIAxes;
app.ax.NextPlot='replace';
newplot(app.ax) % ←追加
end
もっとシンプルに、claで座標軸をクリアする方法や、プロットのオブジェクトをdeleteする方法でも可能です。
function DeleteButtonPushed(app, event)
cla(app.ax)
end
あるいは
function DrawButtonPushed(app, event)
app.ax = app.UIAxes;
app.fp = fimplicit(app.UIAxes,@(id,iq) id.^2+iq.^2 - 10^2); % ハンドルオブジェクトを変数app.fpとして保存
end
function DeleteButtonPushed(app, event)
delete(app.fp)
end
  댓글 수: 1
高木 範明
高木 範明 2023년 10월 16일
グラフ削除に関してこれだけの方法があることをご教示いただき、ありがとうございました。
newplot(app.ax)は座標軸までイニシャライズされるため、cla(app.ax)を使わせていただきました。
本当に助かりました。

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 グラフィックス出力のターゲットの指定에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!