Pick a phrase to print depending on the time of day.

6 views (last 30 days)
I have a cell array which is the code below.
greetcell = {'Good morning', 'Good afternoon','Good evening'};
I need to pick one depends on the time of the day. Like if it is at night, it should be pick hte phrase : Good evening. However, I do not know what code should I put in for the time difference.
  1 Comment
Geoff Hayes
Geoff Hayes on 17 Nov 2014
David - you will need to define the time periods that correspond to morning, day, and night. Whichever period the current timer falls into, 1 or 2 or 3, then that will tell you which message to retrieve (the first or second or third).

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 17 Nov 2014
David, meet clock!
This should get you started:
t = clock;
hr = t(4);

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!