Cody

# Problem 43667. Use a timetable to analyze a train timetable (Part 4)

Solution 2121094

Submitted on 7 Feb 2020 by malues
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
DepTime = datetime(2016,11,[1;1;1;1;1;1;2;2;2;2;3;3;3;3;3],... [6;7;7;8;8;9;4;6;8;3;10;5;8;4;2],[22;27;39;43;46;17;41;40;10;8;30;58;21;36;14],0); ArrTime = datetime(2016,11,[1;1;1;1;1;1;2;2;2;2;3;3;3;3;3],... [9;10;10;13;11;12;7;9;11;6;13;8;11;7;5],[17;32;09;03;26;46;13;20;19;28;40;38;27;32;24],0); Destination = categorical([1;2;1;1;1;1;2;1;3;2;1;3;3;1;2],1:3,{'BOS';'NYC';'DC'}); tt = timetable(DepTime,Destination,ArrTime); Dur = [duration(3,9,05);duration(2,55,15);duration(3,0,24)]; ttDur = myFun(tt); assert(all(abs(ttDur - Dur) <= 0.01))

[Warning: Successfully converted the text to datetime using the format 'MM/dd/uuuu HH:mm:ss', but the format is ambiguous and could also be 'dd/MM/uuuu HH:mm:ss'. To create datetimes from text with a specific format call: datetime(textinput,'InputFormat',infmt) ] [> In guessFormat (line 67) In datetime (line 632) In matlab.internal.datetime.text2timetype (line 75) In timerange>text2Timetype_helper (line 449) In timerange/endpoints2Timetype (line 214) In timerange (line 114) In myFun (line 2) In ScoringEngineTestPoint1 (line 8) In solutionTest (line 3)] [Warning: Successfully converted the text to datetime using the format 'MM/dd/uuuu HH:mm:ss', but the format is ambiguous and could also be 'dd/MM/uuuu HH:mm:ss'. To create datetimes from text with a specific format call: datetime(textinput,'InputFormat',infmt) ] [> In guessFormat (line 67) In datetime (line 632) In matlab.internal.datetime.text2timetype (line 73) In timerange>text2Timetype_helper (line 433) In timerange/endpoints2Timetype (line 221) In timerange (line 114) In myFun (line 2) In ScoringEngineTestPoint1 (line 8) In solutionTest (line 3)] S1 = timetable timerange subscript: Select timetable rows with times in the half-open interval: [01-Nov-2016 00:00:00, 01-Nov-2016 23:59:59) See Select Timetable Data by Row Time and Variable Type. [Warning: Successfully converted the text to datetime using the format 'MM/dd/uuuu HH:mm:ss', but the format is ambiguous and could also be 'dd/MM/uuuu HH:mm:ss'. To create datetimes from text with a specific format call: datetime(textinput,'InputFormat',infmt) ] [> In guessFormat (line 67) In datetime (line 632) In matlab.internal.datetime.text2timetype (line 75) In timerange>text2Timetype_helper (line 449) In timerange/endpoints2Timetype (line 214) In timerange (line 114) In myFun (line 3) In ScoringEngineTestPoint1 (line 8) In solutionTest (line 3)] [Warning: Successfully converted the text to datetime using the format 'MM/dd/uuuu HH:mm:ss', but the format is ambiguous and could also be 'dd/MM/uuuu HH:mm:ss'. To create datetimes from text with a specific format call: datetime(textinput,'InputFormat',infmt) ] [> In guessFormat (line 67) In datetime (line 632) In matlab.internal.datetime.text2timetype (line 73) In timerange>text2Timetype_helper (line 433) In timerange/endpoints2Timetype (line 221) In timerange (line 114) In myFun (line 3) In ScoringEngineTestPoint1 (line 8) In solutionTest (line 3)] S2 = timetable timerange subscript: Select timetable rows with times in the half-open interval: [02-Nov-2016 00:00:00, 02-Nov-2016 23:59:59) See Select Timetable Data by Row Time and Variable Type. [Warning: Successfully converted the text to datetime using the format 'MM/dd/uuuu HH:mm:ss', but the format is ambiguous and could also be 'dd/MM/uuuu HH:mm:ss'. To create datetimes from text with a specific format call: datetime(textinput,'InputFormat',infmt) ] [> In guessFormat (line 67) In datetime (line 632) In matlab.internal.datetime.text2timetype (line 75) In timerange>text2Timetype_helper (line 449) In timerange/endpoints2Timetype (line 214) In timerange (line 114) In myFun (line 4) In ScoringEngineTestPoint1 (line 8) In solutionTest (line 3)] [Warning: Successfully converted the text to datetime using the format 'MM/dd/uuuu HH:mm:ss', but the format is ambiguous and could also be 'dd/MM/uuuu HH:mm:ss'. To create datetimes from text with a specific format call: datetime(textinput,'InputFormat',infmt) ] [> In guessFormat (line 67) In datetime (line 632) In matlab.internal.datetime.text2timetype (line 73) In timerange>text2Timetype_helper (line 433) In timerange/endpoints2Timetype (line 221) In timerange (line 114) In myFun (line 4) In ScoringEngineTestPoint1 (line 8) In solutionTest (line 3)] S3 = timetable timerange subscript: Select timetable rows with times in the half-open interval: [03-Nov-2016 00:00:00, 03-Nov-2016 23:59:59) See Select Timetable Data by Row Time and Variable Type. ttDaily = 3×1 duration array 03:09:50 02:55:15 03:00:24