フィルターのクリア

アプリケーションデザ​​イナーで、グラ​フ​を消す方法を教​えて​いただけないでし​ょ​うか?(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 Center および File Exchangeグラフィックス出力のターゲットの指定 についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!