Executing two timer functions continuously. GUI.
Mostrar comentarios más antiguos
Dear experts,
this is Carlos Andreu. Several months ago, You helped me to refresh continously a textbox with a timer function. This solution has worked perfectly. Now, I would like to add other timer function in order to refresh two text boxes at the same time. I have tried it with the following code:
function myGUI(handles,hObject)
TimerH = timer('UserData', handles.text5, 'TimerFcn', @myTimerFcn, 'Period', 0.5, ...
'ExecutionMode', 'fixedRate');
drawnow;
TimerH2 = timer('UserData', handles.text9, 'TimerFcn', @myTimerFcn2, 'Period', 0.6, ...
'ExecutionMode', 'fixedRate');
drawnow;
start([TimerH TimerH2]);
function myTimerFcn(TimerH,eventData,handles,hObject)
global distance
global flag_tracker
if flag_tracker == 1
TextH = get(TimerH, 'UserData');
distancia = Guardar_pos(TextH);
pause(0.5)
set(TextH,'String',num2str(distance))
drawnow();
else
TextH = get(TimerH, 'UserData');
set(TextH,'String','Measuring...');
end
function myTimerFcn2(TimerH2,eventData,handles,hObject)
global distance2
global flag_tracker
if flag_tracker == 1
TextH2 = get(TimerH2, 'UserData');
distancia_fija = Guardar_pos3(TextH2);
pause(0.5)
set(TextH2,'String',num2str(distance2))
drawnow();
else
TextH2 = get(TimerH2, 'UserData');
set(TextH2,'String','Measuring...');
end
The problem is the textbox of timerH works, but textbox of timerH2 doesn't.
Please, Can you help me?
Thank you in advance,
Carlos.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Entering Commands en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!