Cody

Problem 1576. Mean and standard deviation of times in string

Solution 2265849

Submitted on 9 May 2020
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   Fail
x = {'45.5','1:04.8','55.4'}; y_correct = '55.2'; z_correct = '9.7' [a,b]=mean_std(x); assert(isequal(a,y_correct)&isequal(b,z_correct))

z_correct = '9.7' t = 1×3 cell array {'1:38.4'} {'2:12.9'} {'2:00.6'}

Error using dtstr2dtvecmx Failed to convert from text to date number. Error in datevec (line 123) y = dtstr2dtvecmx(t,icu_dtformat); Error in mean_std (line 5) [Y, M, D, H, MN, S] = datevec(t,'HH:MM:SS.FFF'); Error in Test1 (line 4) [a,b]=mean_std(x);

2   Fail
x = {'1:38.4','2:12.9','2:00.6'}; y_correct = '1:57.3'; z_correct = '17.5'; [a,b]=mean_std(x); assert(isequal(a,y_correct)&isequal(b,z_correct))

t = 1×3 cell array {'1:38.4'} {'2:12.9'} {'2:00.6'}

Error using dtstr2dtvecmx Failed to convert from text to date number. Error in datevec (line 123) y = dtstr2dtvecmx(t,icu_dtformat); Error in mean_std (line 5) [Y, M, D, H, MN, S] = datevec(t,'HH:MM:SS.FFF'); Error in Test2 (line 4) [a,b]=mean_std(x);

3   Fail
x = {'10:00.0','5:00.0','3:00.0','1:00.0'}; y_correct = '4:45.0'; z_correct = '3:51.7'; [a,b]=mean_std(x); assert(isequal(a,y_correct)&isequal(b,z_correct))

t = 1×3 cell array {'1:38.4'} {'2:12.9'} {'2:00.6'}

Error using dtstr2dtvecmx Failed to convert from text to date number. Error in datevec (line 123) y = dtstr2dtvecmx(t,icu_dtformat); Error in mean_std (line 5) [Y, M, D, H, MN, S] = datevec(t,'HH:MM:SS.FFF'); Error in Test3 (line 4) [a,b]=mean_std(x);

4   Fail
x = {'1:01.1','2:02.2','3:03.3','4:04.4'}; y_correct = '2:32.8'; z_correct = '1:18.9'; [a,b]=mean_std(x); assert(isequal(a,y_correct)&isequal(b,z_correct))

t = 1×3 cell array {'1:38.4'} {'2:12.9'} {'2:00.6'}

Error using dtstr2dtvecmx Failed to convert from text to date number. Error in datevec (line 123) y = dtstr2dtvecmx(t,icu_dtformat); Error in mean_std (line 5) [Y, M, D, H, MN, S] = datevec(t,'HH:MM:SS.FFF'); Error in Test4 (line 4) [a,b]=mean_std(x);

5   Fail
x = {'50.7','1:02.3','59.4','57.3','1:00.4'}; y_correct = '58.0'; z_correct = '4.5'; [a,b]=mean_std(x); assert(isequal(a,y_correct)&isequal(b,z_correct))

t = 1×3 cell array {'1:38.4'} {'2:12.9'} {'2:00.6'}

Error using dtstr2dtvecmx Failed to convert from text to date number. Error in datevec (line 123) y = dtstr2dtvecmx(t,icu_dtformat); Error in mean_std (line 5) [Y, M, D, H, MN, S] = datevec(t,'HH:MM:SS.FFF'); Error in Test5 (line 4) [a,b]=mean_std(x);

Suggested Problems

More from this Author9

Community Treasure Hunt

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

Start Hunting!