Filter löschen
Filter löschen

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

8 Ansichten (letzte 30 Tage)
高木 範明
高木 範明 am 16 Okt. 2023
Kommentiert: 高木 範明 am 16 Okt. 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 Kommentar
高木 範明
高木 範明 am 16 Okt. 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');

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu グラフィックス出力のターゲットの指定 finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!