how to make a function

1 view (last 30 days)
Hi everyone;
I am going to make a function that takes starting timing of two movies.like hr1,hr2,min1,min2,and their durations, durnmin1,durmin2 and decides whether we can binge and watch both movies. The criteria are that they must not overlap and that we are not going to wait more than 30 minutes between the end of one and the beginning of the next. It returns true if the criteria are both met and returns false otherwise. You may assume that movie start times are always after 1 pm and before midnight. You may also assume that the first one starts earlier. The order of the input arguments is: hr1, min1, durmin1, hr2, min2, durmin2.
I am unable to understand what will my function will do.what are these timing hr1,hr2? why duration has been given.In that function what i have to do...Thanks in advance for assistance

Accepted Answer

Walter Roberson
Walter Roberson on 22 May 2015
You need to add the first duration to the first start time in order to figure out when the first one ends. Then you need to figure out how much time there is between the projected end time of the first one, and the start of the second. If the second one would start before the first one is projected to end then they overlap. If the second one would start more than 30 minutes after the first one is projected to end then they are too far apart to be desired.
  5 Comments
Walter Roberson
Walter Roberson on 23 May 2015
You did not check for the case where the second one starts before the first one ends.
Muhammad Usman Saleem
Muhammad Usman Saleem on 24 May 2015
I do not get you assistance. I think you are saying me to change if h2-h1>=30/60 && h2-h1~=0 that??

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!