How to get a user to input a time?

6 次查看(过去 30 天)
thebasher
thebasher 2014-2-28
评论: thebasher 2014-2-28
Hello
I'm looking to prompt the user to input a time in HH:MM. I then need to check to see if it is a valid time of day. The user needs to input four separate times for the day. Any ideas on how I can start or perhaps any functions you can recommend?

回答(1 个)

Walter Roberson
Walter Roberson 2014-2-28
t1 = input('Enter first time in HH:MM', 's');
Now you can do the checking on the string that is in t1.
  1 个评论
thebasher
thebasher 2014-2-28
But what if the user misreads it completely, and writes "One o'clock, or 13:00, or 1pm or 3:00am", how can I make sure there are strict parameters that need to be followed? Is there a more efficient way perhaps?
Thanks for your reply.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by