Cody

# Problem 44480. The average of the second largest values

Solution 2655686

Submitted on 5 Jul 2020 by Ramesh Kumar V
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))

m = 3 n = 4 sum = 0 z = 1 2 3 4 z1 = 4 3 2 1 z2 = 3 sum = 3 z = 8 7 6 5 z1 = 8 7 6 5 z2 = 7 sum = 10 z = 9 0 1 4 z1 = 9 4 1 0 z2 = 4 sum = 14 y = 4.6667

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

m = 4 n = 2 sum = 0 z = 2 4 z1 = 4 2 z2 = 2 sum = 2 z = 5 9 z1 = 9 5 z2 = 5 sum = 7 z = 0 5 z1 = 5 0 z2 = 0 sum = 7 z = 88 52 z1 = 88 52 z2 = 52 sum = 59 y = 14.7500

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))

m = 3 n = 5 sum = 0 z = 97 93 68 58 24 z1 = 97 93 68 58 24 z2 = 93 sum = 93 z = 74 55 49 40 24 z1 = 74 55 49 40 24 z2 = 55 sum = 148 z = 63 53 46 37 19 z1 = 63 53 46 37 19 z2 = 53 sum = 201 y = 67

4   Pass
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))

m = 6 n = 5 sum = 0 z = 82 65 14 40 44 z1 = 82 65 44 40 14 z2 = 65 sum = 65 z = 73 81 18 53 2 z1 = 81 73 53 18 2 z2 = 73 sum = 138 z = 15 46 40 42 99 z1 = 99 46 42 40 15 z2 = 46 sum = 184 z = 66 44 84 66 17 z1 = 84 66 66 44 17 z2 = 66 sum = 250 z = 52 83 81 63 11 z1 = 83 81 63 52 11 z2 = 81 sum = 331 z = 98 9 7 30 38 z1 = 98 38 30 9 7 z2 = 38 sum = 369 y = 61.5000

### Community Treasure Hunt

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

Start Hunting!