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

5 visualizzazioni (ultimi 30 giorni)
高木 範明
高木 範明 il 16 Ott 2023
Commentato: 高木 範明 il 16 Ott 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 Commento
高木 範明
高木 範明 il 16 Ott 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');

Accedi per commentare.

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!