hello every one ...i need program for clock..or for e.g need code to write clock
Show older comments
my name is Masoud i study M.s mechanic engineer .i don't work for build clock but i use other code to Matlab... thank you for answer this question
11 Comments
Walter Roberson
on 29 Nov 2015
What does the clock need to do ?
masoud mansouri
on 29 Nov 2015
John D'Errico
on 29 Nov 2015
Look on the file exchange.
Jan
on 29 Nov 2015
@masoud: In the first part of the comment, you state, that you do not need the tic, toc behavior. Then you explain exactly the purpose of tic toc explicitly. Therefore I still do not understand what you want. Please post a small example what should appeare where. And please post this by editing the original question, not hidden in a list of comments. Thanks.
Image Analyst
on 29 Nov 2015
What does "i use other code to Matlab" mean? Do you mean that you have code that also doesn't work in some other language, such as C, Java, or Python? Do you want to write this in MATLAB or not?
Shameer Parmar
on 1 Dec 2015
Edited: Shameer Parmar
on 1 Dec 2015
@Masoud: I also not able to understand your exact requirement, but I guess you need code to display current time and date.
Try for this command in Matlab command window, if this can help you..--> java.util.Date()
you can use following code to split it and can store into separate var.
timeStr = char(java.util.Date());
day = timeStr(1:3);
month = timeStr(5:7);
date = timeStr(9:11);
time = timeStr(12:19);
timeZone = timeStr(21:23);
year = timeStr(25:28);
masoud mansouri
on 2 Dec 2015
Edited: Image Analyst
on 2 Dec 2015
Thorsten
on 2 Dec 2015
So what is this clock program supposed to do?
masoud mansouri
on 2 Dec 2015
Image Analyst
on 2 Dec 2015
We don't know what you want. Specifically, you said you searched the File Exchange like John suggested but found nothing. But when I search it ( http://www.mathworks.com/matlabcentral/fileexchange/?utf8=%E2%9C%93&term=clock It brought up lots of clocks. Why don't any of them work? What about Thorsten's answer below, or Jan or Shameer's comments above using simple date and time strings and functions built into MATLAB? What's wrong with them?
masoud mansouri
on 3 Dec 2015
Accepted Answer
More Answers (1)
To show the current date and time, use
datestr(now)
If you want to measure the time, you can use tic; toc or clock and etime, as explained in
help etime
Categories
Find more on Clocks and Timers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!