App Designer UIAxes overwritting

Hello,
I programmed a app where I can simulate two thermodynamic cycle process . It starts simulating by pressing Start.
But now I have the problem that the 2 processes are overwriting eachother.
Do you know how its possible to delete one of the processes before starting the other?
Here is the code where you can see that I put app.UIAxes in it that it will show the function on the Diagram
Its only the Code from the Constant Pressure Cycle ( 2nd Start button) and it shows only the plotfunctions
plot(app.UIAxes, [V12_Gdp V23_Gdp V34_Gdp V41_Gdp], [ p12_Gdp p23_Gdp p34_Gdp p41_Gdp], "Color", [ 0 0 0], "LineWidth",1.5)
hold(app.UIAxes,'on')
grid on
xlabel("Volumen in m^3/kg")
ylabel("Druck in MPa")
title("Gleichdruckprozess p-V Diagramm")
% 2D-Animation - Slow Marker
hold on
% Startpunkt markieren mit einem rotem 'Marker' bei V1 & p1
p_Gdp = plot(app.UIAxes, V1_Gdp, p1_Gdp, 'o', 'MarkerFaceColor','red')
hold off
hold(app.UIAxes,'on')
for i_Gdp = 1:length(V12_Gdp)
p_Gdp.XData = V12_Gdp(i_Gdp);
p_Gdp.YData = p12_Gdp(i_Gdp);
% V, p Daten nebenher anzeigen lassen mit 3 Dezimalstellen nach dem
% Komma
s_Gdp = sprintf ( ' %0.3f, %0.3f',V12_Gdp(i_Gdp),p12_Gdp(i_Gdp));
ht_Gdp = text(app.UIAxes, V12_Gdp(i_Gdp),p12_Gdp(i_Gdp),s_Gdp,'color','[1 0 0]','FontSize',14 );
drawnow
delete(ht_Gdp);
end
for i_Gdp = 1:length(V23_Gdp)
p_Gdp.XData = V23_Gdp(i_Gdp);
p_Gdp.YData = p23_Gdp(i_Gdp);
% V, p Daten nebenher anzeigen lassen mit 3 Dezimalstellen nach dem
% Komma
s_Gdp = sprintf ( ' %0.3f, %0.3f',V23_Gdp(i_Gdp),p23_Gdp(i_Gdp));
ht_Gdp = text(app.UIAxes, V23_Gdp(i_Gdp),p23_Gdp(i_Gdp),s_Gdp,'color','[1 0 0]','FontSize',14 );
drawnow
delete(ht_Gdp);
end
for i_Gdp = 1:length(V23_Gdp)
p_Gdp.XData = V34_Gdp(i_Gdp);
p_Gdp.YData = p34_Gdp(i_Gdp);
% V, p Daten nebenher anzeigen lassen mit 3 Dezimalstellen nach dem
% Komma
s_Gdp = sprintf ( ' %0.3f, %0.3f',V34_Gdp(i_Gdp),p34_Gdp(i_Gdp));
ht_Gdp = text(app.UIAxes, V34_Gdp(i_Gdp),p34_Gdp(i_Gdp),s_Gdp,'color','[1 0 0]','FontSize',14 );
drawnow
delete(ht_Gdp);
end
for i_Gdp = 1:length(V41_Gdp)
p_Gdp.XData = V41_Gdp(i_Gdp);
p_Gdp.YData = p41_Gdp(i_Gdp);
% V, p Daten nebenher anzeigen lassen mit 3 Dezimalstellen nach dem
% Komma
s_Gdp = sprintf ( ' %0.3f, %0.3f',V41_Gdp(i_Gdp),p41_Gdp(i_Gdp));
ht_Gdp = text(app.UIAxes, V41_Gdp(i_Gdp),p41_Gdp(i_Gdp),s_Gdp,'color','[1 0 0]','FontSize',14 );
drawnow
delete(ht_Gdp);
end
hold(app.UIAxes,'off')
Best Regards Eduard

Answers (1)

Eduard Spomer
Eduard Spomer on 15 May 2022
Hello, I solved the problem using delete(plot)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Asked:

on 15 May 2022

Answered:

on 15 May 2022

Community Treasure Hunt

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

Start Hunting!