Matlab Timer , time format

조회 수: 6 (최근 30일)
reddy red
reddy red 2022년 4월 22일
답변: reddy red 2022년 4월 22일
Hello All,
I am using "timer" to capture time between two events in matlab. And timer call back function reports time in seconds. Is there any way to change the format, like i want to report the time in hh:mm:ss format. In the application i have to display every 1 second time interval and it is reporting time for every one 1 second. I want to report the time in hh;mm:ss format. Is there a way to change the time display format using "timer" function

답변 (1개)

reddy red
reddy red 2022년 4월 22일
//below is the code for timer declaration
t_obj = timer;
t_obj.ExecutionMode = 'fixedRate';
t_obj.Period = 1; % seconds
t_obj.StartDelay = 0;
t_obj.TimerFcn = @(~,~)set(handles.timeStr,'String',regexprep(handles.timeStr.String,'^\d+','${num2str(str2double($0)+1)}'));
// code for using starting timer
function pushbuttoncallback((hObject, eventdata, handles)
handles = guidata(hObject);
start(handles.timer)
// execute code : time taken to run code is mimicked by pause function
pause(10)
stop(handles.timer);
end

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by