Cody

Solution 1448126

Submitted on 23 Feb 2018
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
x = [1 2 3 4;8 7 6 5;9 0 1 4]; y_correct = (3 + 7 + 4) / 3; assert(isequal(ave_2ndM(x),y_correct))

x2 = 1 2 3 4 8 7 6 5 9 0 1 4 max1 = 4 8 9 ind1 = 4 1 1 x2 = 1 2 3 NaN NaN 7 6 5 NaN 0 1 4 max2 = 3 7 4 ind2 = 3 2 4 y = 4.6667

2   Fail
x = [2 4 ;5 9; 0 5;88 52]; y_correct = (2 + 5 + 0 + 52) / 4; assert(isequal(ave_2ndM(x),y_correct))

x2 = 2 4 5 9 0 5 88 52 max1 = 4 9 5 88 ind1 = 2 2 2 1

Error using sub2ind (line 51) The subscript vectors must all be of the same size. Error in ave_2ndM (line 6) x2(sub2ind(size(x),[1:3],ind1'))=NaN Error in Test2 (line 3) assert(isequal(ave_2ndM(x),y_correct))

3   Pass
x = [97 93 68 58 24 74 55 49 40 24 63 53 46 37 19]; y_correct = (93 + 55 + 53) / 3; assert(isequal(ave_2ndM(x),y_correct))

x2 = 97 93 68 58 24 74 55 49 40 24 63 53 46 37 19 max1 = 97 74 63 ind1 = 1 1 1 x2 = NaN 93 68 58 24 NaN 55 49 40 24 NaN 53 46 37 19 max2 = 93 55 53 ind2 = 2 2 2 y = 67

4   Fail
x = [ 82 65 14 40 44 73 81 18 53 2 15 46 40 42 99 66 44 84 66 17 52 83 81 63 11 98 9 7 30 38]; y_correct = 61.5; assert(isequal(ave_2ndM(x),y_correct))

x2 = 82 65 14 40 44 73 81 18 53 2 15 46 40 42 99 66 44 84 66 17 52 83 81 63 11 98 9 7 30 38 max1 = 82 81 99 84 83 98 ind1 = 1 2 5 3 2 1

Error using sub2ind (line 51) The subscript vectors must all be of the same size. Error in ave_2ndM (line 6) x2(sub2ind(size(x),[1:3],ind1'))=NaN Error in Test4 (line 8) assert(isequal(ave_2ndM(x),y_correct))