Problem with Matlab gui quitting

1 view (last 30 days)
Stewart Tan
Stewart Tan on 3 Oct 2019
Answered: Ajay Kumar on 3 Oct 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?

Answers (1)

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

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!