Problem with Matlab gui quitting

1 Ansicht (letzte 30 Tage)
Stewart Tan
Stewart Tan am 3 Okt. 2019
Beantwortet: Ajay Kumar am 3 Okt. 2019
So i want to create a gui which is basically a timer which counts down from 30 minutes.
Which is something like above. Whenever i click the "Run" button to execute the GUI, the timer will display and countdown.
The code i used is:
function countdown(app)
while true
minute = 29;
set(app.ParallelPoolidletimerTextArea, 'Value', num2str(minute));
seconds = 0;
set(app.TextArea, 'Value', num2str(seconds));
while minute > 0
seconds = 59;
while seconds > 0
set(app.TextArea, 'Value', num2str(seconds));
pause(1);
seconds = seconds - 1;
end
minute = minute - 1;
set(app.ParallelPoolidletimerTextArea, 'Value', num2str(minute));
end
end
end
Since the GUI has a startup function, i just did:
function startupFcn(app)
app.countdown;
end
Hence the countdown works, but the problem is when i quit the application, Matlab throws me an error saying:
Invalid or deleted object.
Error in app.countdown.
Error in runStartupFcn(app, @startupFcn)
Why is this happening?

Antworten (1)

Ajay Kumar
Ajay Kumar am 3 Okt. 2019
Try this:
write countdown(app) instead of app.countdown in startupFcn.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by