Problem with Matlab gui quitting

조회 수: 1 (최근 30일)
Stewart Tan
Stewart Tan 2019년 10월 3일
답변: Ajay Kumar 2019년 10월 3일
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?

답변 (1개)

Ajay Kumar
Ajay Kumar 2019년 10월 3일
Try this:
write countdown(app) instead of app.countdown in startupFcn.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by