From: David on 6 Aug 2010 09:57 Hi! I am new to programming and I have a question. I have a GUI window that I created without using GUIDE. There is a start Timer push button and an edit window next to it. When the Start Timer button is pressed it starts a timer using tic. I want the running elapsed time to be shown in the edit window, like a timer on a watch. I can not seem to get this to work, any suggestions? Additionally is there a way to stop the tic timer from running in the background? Thank you, Nicole
From: Sean on 6 Aug 2010 10:34 "David " <drjengr(a)aol.com> wrote in message <i3h4bg$8vp$1(a)fred.mathworks.com>... > Hi! I am new to programming and I have a question. I have a GUI window that I created without using GUIDE. There is a start Timer push button and an edit window next to it. When the Start Timer button is pressed it starts a timer using tic. I want the running elapsed time to be shown in the edit window, like a timer on a watch. I can not seem to get this to work, any suggestions? Additionally is there a way to stop the tic timer from running in the background? > Thank you, > Nicole Use a timer function (doc timer) that updates the 'String' property of your edit box every differential time period you want. Eg. if you want it to update every 1 second: %%% toc_it = @set(handles.editbox,'String',toc); t = timer('TimerFcn',toc_it, 'Period', 1.0); tic start(t); %%%
From: David on 6 Aug 2010 10:57 "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i3h6gs$12c$1(a)fred.mathworks.com>... > "David " <drjengr(a)aol.com> wrote in message <i3h4bg$8vp$1(a)fred.mathworks.com>... > > Hi! I am new to programming and I have a question. I have a GUI window that I created without using GUIDE. There is a start Timer push button and an edit window next to it. When the Start Timer button is pressed it starts a timer using tic. I want the running elapsed time to be shown in the edit window, like a timer on a watch. I can not seem to get this to work, any suggestions? Additionally is there a way to stop the tic timer from running in the background? > > Thank you, > > Nicole > > Use a timer function (doc timer) that updates the 'String' property of your edit box every differential time period you want. > > Eg. if you want it to update every 1 second: > %%% > toc_it = @set(handles.editbox,'String',toc); > t = timer('TimerFcn',toc_it, 'Period', 1.0); > tic > start(t); > %%% Thanks, I really appreciate it! I had a tic timer running in the background and when i added that code it updated the Edit window every time I pressed the start timer button. When I restarted Matlab and did not have a timer running already I received an error message saying that I must run tic first.
From: Sean on 6 Aug 2010 11:19 "David " <drjengr(a)aol.com> wrote in message <i3h7s0$qou$1(a)fred.mathworks.com>... > "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i3h6gs$12c$1(a)fred.mathworks.com>... > > "David " <drjengr(a)aol.com> wrote in message <i3h4bg$8vp$1(a)fred.mathworks.com>... > > > Hi! I am new to programming and I have a question. I have a GUI window that I created without using GUIDE. There is a start Timer push button and an edit window next to it. When the Start Timer button is pressed it starts a timer using tic. I want the running elapsed time to be shown in the edit window, like a timer on a watch. I can not seem to get this to work, any suggestions? Additionally is there a way to stop the tic timer from running in the background? > > > Thank you, > > > Nicole > > > > Use a timer function (doc timer) that updates the 'String' property of your edit box every differential time period you want. > > > > Eg. if you want it to update every 1 second: > > %%% > > toc_it = @set(handles.editbox,'String',toc); > > t = timer('TimerFcn',toc_it, 'Period', 1.0); > > tic > > start(t); > > %%% > > Thanks, I really appreciate it! I had a tic timer running in the background and when i added that code it updated the Edit window every time I pressed the start timer button. When I restarted Matlab and did not have a timer running already I received an error message saying that I must run tic first. To elaborate: Since you want it to continuously update: T = timer('TimerFcn',myfun,'Period', 1,'ExecutionMode','FixedRate'); set the execution mode to fixedrate also in my function above, you'll most likely need this: toc_it = @(obj,evnt)set(handles.editbox,'String',toc); Good Luck
|
Pages: 1 Prev: mcc -m Next: Really need help with Maximum Likelihood estimation and Kalman Filter |