MATLAB Timer Function w/ Compiler
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Here is the scenerio I am running into. I have a GUI with a start/stop button and an "indicator status light" that controls the start/stop of a timer function. If the light is red when the button is pushed then the timer is not running and it executes "SimTimerFcn" to start the timer. If it is green - it knows it needs to stop the timer and does that. The timer calls another funtion which looks at the contents of a folder to find files it needs to process. All this works great within MATLAB but when it complies it does not work... it seems like its not even trying to run the first iteration. I have tried wait and waitfor and nothing seems to be working... any ideas? I assume I am putting the wait statement in the wrong place or something but this one as thrown me for a loop. Thanks!


6 comentarios
Geoff Hayes
el 28 de En. de 2020
Editada: Geoff Hayes
el 28 de En. de 2020
I wonder if this https://www.mathworks.com/matlabcentral/answers/283132-timer-does-not-work-in-the-exe-file#answer_221301 is the problem. You are creating a local variable timer in the SimTimerFcn and then as soon as that function completes, the timer is deleted. You may want to save the timer to the hMainGUI_Handles structure. So your SimTimerFcn code might look like
function SimTimerFcn
hMainGUI = getappdata(0, 'hMainGUI');
hMainGUI_handles = getappdata(0, 'hMainGUI_handles');
hMainGUI_handles.timer = timer;
% etc.
setappdata(0,'hMainGUI_handles', hMainGUI_handles);
start(hMainGUI_handles.timer);
Or something similar to that (I'm not sure if all the syntax is correct...)
You could also move the SimTimerFcn code to the SimStartStop function where you would already have access to the hMainGUI_handles.
Respuestas (0)
Ver también
Categorías
Más información sobre Application Deployment en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!