Cody

# Problem 44279. Find the mean of a 2-D matrix after excluding elements of specified sub-matrix

Solution 2977864

Submitted on 22 Sep 2020 by Benjamin
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
Ax = [1 2 3 4 5 6; 11 12 13 14 15 16; 21 22 23 24 25 26; 31 32 33 34 35 36; 41 42 43 44 45 46; 51 52 53 54 55 56]; r1x = 0; r2x = 4; c1x = 1; c2x = 4; y_correct = 31.7; assert(isequal(mean2d_excl(Ax,r1x,r2x,c1x,c2x),y_correct));

A = 1 NaN NaN 4 5 6 11 NaN NaN 14 15 16 21 NaN NaN 24 25 26 31 32 33 34 35 36 41 42 43 44 45 46 51 52 53 54 55 56 ans = 31.7000

2   Pass
Ax = [1 2 3 4 5 6; 11 12 13 14 15 16; 21 22 23 24 25 26; 31 32 33 34 35 36; 41 42 43 44 45 46; 51 52 53 54 55 56]; r1x = 1; r2x = 4; c1x = 1; c2x = 4; y_correct = 29.875; assert(isequal(mean2d_excl(Ax,r1x,r2x,c1x,c2x),y_correct));

A = 1 2 3 4 5 6 11 NaN NaN 14 15 16 21 NaN NaN 24 25 26 31 32 33 34 35 36 41 42 43 44 45 46 51 52 53 54 55 56 ans = 29.8750

3   Pass
Ax = [1 2 3 ; 12 13 14; 24 25 26]; r1x = 1; r2x = 4; c1x = 1; c2x = 4; y_correct = 8.4; assert(isequal(mean2d_excl(Ax,r1x,r2x,c1x,c2x),y_correct));

A = 1 2 3 12 NaN NaN 24 NaN NaN ans = 8.4000

### Community Treasure Hunt

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

Start Hunting!