f



Countdown Timer in MATLAB GUI

Good day! I saw the following codes on this page: http://www.mathworks.com/help/matlab/matlab_prog/use-a-matlab-timer-object.html

t = timer('TimerFcn', 'stat=false; disp(''Timer!'')',... 
                 'StartDelay',10);
start(t)

stat=true;
while(stat==true)
  disp('.')
  pause(1)
end

It actually works however it diplays something like this due to its configuration:

..
..
..
..
..
..
..
..
..
..
Timer!


My question is that: is there a way that all the dots could appear as different numbers? As if the result would look like a countdown timer (as shown below) that could be used in MATLAB GUI. Thank you so much!

10
9
8
7
6
5
4
3
2
1
0
0
Mary
8/10/2015 3:55:03 PM
comp.soft-sys.matlab 211266 articles. 18 followers. lunamoonmoon (258) is leader. Post Follow

3 Replies
460 Views

Similar Articles

[PageSpeed] 32

"Mary Requilman" wrote in message <mqahgn$6br$1@newscl01ah.mathworks.com>...
> Good day! I saw the following codes on this page: http://www.mathworks.com/help/matlab/matlab_prog/use-a-matlab-timer-object.html
> 
> t = timer('TimerFcn', 'stat=false; disp(''Timer!'')',... 
>                  'StartDelay',10);
> start(t)
> 
> stat=true;
> while(stat==true)
>   disp('.')
>   pause(1)
> end
> 
> It actually works however it diplays something like this due to its configuration:
> 
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> Timer!
> 
> 
> My question is that: is there a way that all the dots could appear as different numbers? As if the result would look like a countdown timer (as shown below) that could be used in MATLAB GUI. Thank you so much!
> 
> 10
> 9
> 8
> 7
> 6
> 5
> 4
> 3
> 2
> 1
> 0

A specific answer to your question would be to modify the above code something like:

stat=true;
dispTime = 10;
while(stat==true)
  disp(dispTime)
  pause(1)
dispTime = dispTime - 1;
end

No guarantee, in general,  you will end at zero, it depends on the values of StartDelay & pause.  You can easily modify the above to be a countup timer instead, if you like.
0
someone
8/10/2015 6:27:02 PM
"someone" wrote in message <mqaqdm$ph0$1@newscl01ah.mathworks.com>...
> "Mary Requilman" wrote in message <mqahgn$6br$1@newscl01ah.mathworks.com>...
> > Good day! I saw the following codes on this page: http://www.mathworks.com/help/matlab/matlab_prog/use-a-matlab-timer-object.html
> > 
> > t = timer('TimerFcn', 'stat=false; disp(''Timer!'')',... 
> >                  'StartDelay',10);
> > start(t)
> > 
> > stat=true;
> > while(stat==true)
> >   disp('.')
> >   pause(1)
> > end
> > 
> > It actually works however it diplays something like this due to its configuration:
> > 
> > .
> > .
> > .
> > .
> > .
> > .
> > .
> > .
> > .
> > .
> > Timer!
> > 
> > 
> > My question is that: is there a way that all the dots could appear as different numbers? As if the result would look like a countdown timer (as shown below) that could be used in MATLAB GUI. Thank you so much!
> > 
> > 10
> > 9
> > 8
> > 7
> > 6
> > 5
> > 4
> > 3
> > 2
> > 1
> > 0
> 
> A specific answer to your question would be to modify the above code something like:
> 
> stat=true;
> dispTime = 10;
> while(stat==true)
>   disp(dispTime)
>   pause(1)
> dispTime = dispTime - 1;
> end
> 
> No guarantee, in general,  you will end at zero, it depends on the values of StartDelay & pause.  You can easily modify the above to be a countup timer instead, if you like.

It worked! Thank you so much!
What if dispTime is set to 120? Which means that the timer will run for 2 minutes. My next concern is that how could the results appear as if it was counting down starting from the two-minute mark? Like:
2:00
1:59
1:58
1:57 ... and so on.
0
Mary
8/11/2015 8:40:03 AM
"Mary Requilman" wrote in message <mqccd3$ckm$1@newscl01ah.mathworks.com>...
> "someone" wrote in message <mqaqdm$ph0$1@newscl01ah.mathworks.com>...
> > "Mary Requilman" wrote in message <mqahgn$6br$1@newscl01ah.mathworks.com>...
> > > Good day! I saw the following codes on this page: http://www.mathworks.com/help/matlab/matlab_prog/use-a-matlab-timer-object.html
>  
.... snip ...
> 
> It worked! Thank you so much!
You're welcome.
> What if dispTime is set to 120? Which means that the timer will run for 2 minutes. My next concern is that how could the results appear as if it was counting down starting from the two-minute mark? Like:
> 2:00
> 1:59
> 1:58
> 1:57 ... and so on.

This is a very basic question.  It may be time to read the "Getting Started With MATLAB" documentation.  If you don't have it, an html version is available here:

<<http://www.mathworks.com/help/matlab/getting-started-with-matlab.html>>

There is even a video link at the bottom of the page.

For an initial try, you might want to just work in seconds (rather than minutes & seconds).  Then once you get that working, then get fancy with the floor, rem, mod, datetime, and/or format commands.
0
someone
8/11/2015 3:02:03 PM
Reply:

Similar Artilces:

Need timer in GUI...Is there a timer in Matlab 7 GUI?
Hi all, In designing a Matlab 7 GUI, I often need to use timer to do something periodically and each time let the timer to trig a callback function... How can I do that? Have you looked at the timer function? http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/ch14_pro.html Stuart "lucy" <losemind@yahoo.com> wrote in message news:cg2vmd$lt6$1@news.Stanford.EDU... > Hi all, > > In designing a Matlab 7 GUI, I often need to use timer to do something > periodically and each time let the timer to trig a callback function... > > How can I do tha...

how to convert a Matlab GUI ,matlab independant
i am working on a project in MATLAB and i want to make it MATLAB independant... So that it can run on any PC without MATLAB or in other words i want to make an EXE file for the entire project...please if any one can tell me exact details what to do with the set of files . my project is mainly executed from a GUI which further opens another GUI. the input files are in .dat format (present in same folder) and the result is also stored in the same directory in .dat format. i hav heard about mcc comand but didnt get how to use it for my project.. please reply... ill be greatfull Regards! Ensure...

starting matlab gui outside matlab
Hello! I have to start my matlab gui outside matlab program (without opening it). Is there something like .bat file in Java for Matlab? Thanks for helping me out... :) Emma Hi Emma, I'm not sure if I understand your question. One way would be to compile the GUI (there is a lot of stuff on that in this forum). Otherwise, if you just want to avoid opening Matlab and loading the file, you can use: 1) a simple .bat file with the following command: matlab -minimize -yourfile.m 2) a shortcut with this line as target (but with the full matlab.exe path), in which you also specify your gui dire...

Access from MATLAB to a non-MATLAB GUIs
Hallo everybody, In one of my MATLAB functions I invoke external EXE file (another program), which makes some calculations. At the end of the calculations a message appears if I want to quit the exernal program (with 'Yes' and 'No' buttons). I want to close this message, because it interrupts the executaion of the whole MATLAB function(a batch file). The message is generated from the exernal program, not from MATLAB, so I can't use a MATLAB handle to close it. So, does anybody knows how I can close those non-MATLAB generated message (GUI) with a command in the MATLAB...

How do I Run a Matlab 6 GUI in Matlab 5
Hi there everyone!! I am designing a Matlab 6 GUI at the university, but have Matlab 5 at home. If I try to run the Matlab 6 Gui,it doesnt want to open. Is there a way to open Matlab 6 GUI's in Matlab 5. Any help will be appreciated Hugo ...

call to matlab function from matlab GUI stalls
I have the following problem. I have created a simple Matlab GUI (for our purposes it can just be considered a Matlab function) which gathers some parameters and then invokes a perl script that in turn calls other perl and Matlab scripts to perform various calculations. If instead of using the Matlab GUI, I run the perl command from the unix prompt, the flow runs and concludes correctly. BUT if I invoke the flow from the Matlab GUI (function), then it runs correctly by calling various other perl and Matlab scripts, but then when it reaches the third Matlab function call, it consistently stalls...

creating GUI in matlab out of some programs written in matlab
I have written some code in matlab for my application. I want to make a graphical interface so that an user can easily use my code. I do not know, how to link my code or a particular function when user clicks on a particular button. I mean, how to assign a function written by me to a push button so that it will execute the function. And how to give the input to my function and get output after executing the particular function. I am quiet familiar with matlab code. But I am absolutely new with GUI in matlab. Please help me to deal with the above problem. On 4/12/2011 12:37 AM, sk maidul haq...

Run Matlab ... from Matlab
Hello, Is there any limitation to run Matlab from Matlab, as a system command, on Linux platforms ? I tried to start Matlab, both using the ! syntax (!matlab&) or the system command (system('matlab&')), the Matlab splash screen appears, but the new Matlab session closes rapidly . When I do the same with a script of mine (system('matlab -r "myscript"&')), my script is being executed, but Matlab finally crashes . If I remove the &, it works well, but the first Matlab session is blocked till I close the second one . I run Matlab on a Linux 64bits pla...

Matlab GUI with timer in the background
Hello everyone, I have a GUI (developed using guide) and I need to show the current time and date in one of its corners, I have written a simple code which works alright, however I am not sure where in the GUI code to use it. When I use the code in GUI_OpeningFcn, which executes just before gui is made visible, it shows the time but MATLAB remains busy and I won't be able to run anything else from the command window, furthermore, I am not sure how to stop the timer and delete the timer when the GUI is closed. When I use handles to save timer created in OpeningFcn and later delete the ti...

MATLAB talking to MATLAB?
For my project, I need to have a client program (MATLAB executable) talking to a server program (also MATLAB executable) to query data. Is there any easy way to accomplish that? I appreciate any help that I can get on that. Thanks. Cheers, Hoi Oops, I forgot to mention. There are multiple clients querying the server, so I guess serial objects + remote serial port wouldn't work. "Hoi Wong" <wonghoi.ee@gmail.com_> wrote in message news:f3ald6$gg4$1@news.Stanford.EDU... > For my project, I need to have a client program (MATLAB executable) > talking to a ser...

Matlab 7 ----> Matlab 6 GUI conversion
Hi, I have a question related to whether it is possible to convert a .fig file that was created in Matlab 7 into Matlab 6. I am running on my machine Matlab 6 and when i am trying to run the gui created in a recent version of Matlab, it fails Thanks George close your pc and go to sleep magka moy ...

Importing matlab 6.5 GUI in matlab 7.1
I use MATLAB 7.1. If I open an existing GUI project built in 6.5 MATLAB with GUIDE tool, .fig is loaded correctly but .m is not loaded (it has the same name of .fig), then when I run the GUI and click on buttons I got function not found errors: ??? Undefined command/function 'fsv'. ??? Error while evaluating uicontrol Callback. How can I reassociate .m with his .fig? ...

How to transfer a VC matrix to matlab workspace and manipulate it under matlab GUI ?
I would like to transfer a VC matrix to matlab main program workspace, than i can observe it by Matlab array editor, or directly manipulate it under matlab GUI. I tried engdemo.c, but i found that under this mode, matlab runs on background, there is no matlab main program GUI, I can only excute matlab command on C, and see result, like ploting. how should this be done ? Thank you so much. "KS " <CHH@itri.org.tw> wrote in message <hs008g$256$1@fred.mathworks.com>... > I would like to transfer a VC matrix to matlab main program workspace, > &...

Matlab Tutorial 10 &#8211; Matlab GUI tutorial
http://learnbyexamples.org Why use a GUI in MATLAB? The main reason GUIs are used is because it makes things simple for the end-users of the program. If GUIs were not used, people would have to work from the command line interface, which can be extremely difficult and fustrating. Imagine if you had to input text commands to operate your web browser (yes, your web browser is a GUI too!). It wouldn&#8217;t be very practical would it? In this tutorial, we will create a simple GUI that will add together two numbers, displaying the answer in a designated text field. This tutorial is written for...

Web resources about - Countdown Timer in MATLAB GUI - comp.soft-sys.matlab

Countdown (game show) - Wikipedia, the free encyclopedia
Countdown is a British game show involving word and number puzzles. It is produced by ITV Studios and broadcast on Channel 4 . It is presented ...

Hype Alert: Countdown To Timeline For Pages, Profiles
... media agency unveiled a webpage that counts down to the start of the Facebook Marketing Conference. The agency’s potentially mislabled countdown ...

Countdown (@C4Countdown) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Countdown to #SB48 Sunday
Are you #UnitedInOrange for the Denver @Broncos or a member of the Seattle @Seahawks #12thman ? Or maybe the @BrunoMars halftime performance ...

Bus London Pro - Live Countdown and Bus Routes on the App Store on iTunes
Get Bus London Pro - Live Countdown and Bus Routes on the App Store. See screenshots and ratings, and read customer reviews.

From school milk to Countdown, it's time to reclaim Australia's glorious past
The government created a drink that was fatal to all but the strong. It was a eugenics scheme written in dairy.

Triple J Hottest 100: Kendrick Lamar could be the countdown king
Who's going to top Triple J's Hottest 100? Wait for Australia Day.

The Super Bowl Top 50 Ad Countdown - Special: Super Bowl - AdAge
In commemoration of the big anniversary, Ad Age is counting down the top 50 Super Bowl ads of all time. This is purely a subjective list cultivated ...

Mike Ditka Proves He's an O.G., Whips Out Bank Roll During 'NFL Countdown' - Bleacher Report
Mike Ditka wore a bright red jacket on Saturday’s edition of NFL Countdown , and fans jabbed him over it on Twitter. However, in truly legendary ...

STICKING TO THEIR GUNS Countdown to open-carry in Texas
STICKING TO THEIR GUNS Countdown to open-carry in Texas

Resources last updated: 1/25/2016 8:59:53 AM