Effacer les filtres
Effacer les filtres

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

6 vues (au cours des 30 derniers jours)
高木 範明
高木 範明 le 16 Oct 2023
Commenté : 高木 範明 le 16 Oct 2023
アプリケーションデザイナーで、「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 commentaire
高木 範明
高木 範明 le 16 Oct 2023
転記ミスがありました。訂正いたします。
  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');

Connectez-vous pour commenter.

Réponse acceptée

Kojiro Saito
Kojiro Saito le 16 Oct 2023
Modifié(e) : Kojiro Saito le 16 Oct 2023
グラフの 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 commentaire
高木 範明
高木 範明 le 16 Oct 2023
グラフ削除に関してこれだけの方法があることをご教示いただき、ありがとうございました。
newplot(app.ax)は座標軸までイニシャライズされるため、cla(app.ax)を使わせていただきました。
本当に助かりました。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur グラフィックス出力のターゲットの指定 dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!