필터 지우기
필터 지우기

update date and time in gui

조회 수: 5 (최근 30일)
Stalin Samuel
Stalin Samuel 2016년 1월 21일
댓글: Rainaire Hansford 2019년 5월 25일
function demo1()
H.f = figure('Name','DEMO1');
set(H.f,'Units','Pixels','Position',get(0,'ScreenSize'));% adjust figure size as per the screen size
H.pb1 = uicontrol('style','push',...
'units','pixels',...
'position',[400 800 280 30],...
'fontsize',14,...
'string', datestr(now)); % datestr(now) is used to get current date and time
end
Now my intention is to update the date and time and it should be run like a real time clock

답변 (1개)

Walter Roberson
Walter Roberson 2016년 1월 21일
You are going to want to use a timer to update the graphics. Odd that you would put it on a pushbutton rather than as a uicontrol('style','text'), but whatever.
The timer that does the update is going to need to get the handle of the graphics object to update. It would find that easier if you returned your H out of your function, or if you had at least added a Tag to the uicontrol so that it could (inefficiently but functionally) search all the graphics objects by name. As it is now, the timer is going to have to locate the figure by name and then dig inside the figure to find the uicontrol...
  댓글 수: 1
Rainaire Hansford
Rainaire Hansford 2019년 5월 25일
Hi Stalin,
Any way to apply your function on a script?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by