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

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

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

David, meet clock!
This should get you started:
t = clock;
hr = t(4);

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!