Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 249208

Submitted on 25 May 2013 by Claudio Gelmi

Correct

125Size
Leading solution size is 15.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
A = 127*ones(5,4)
B_correct = [56 85 85 56; 85 127 127 85; 85 127 127 85; 85 127 127 85; 56 85 85 56]
assert(isequal(med_filt(A),B_correct))
clear all
A =
   127   127   127   127
   127   127   127   127
   127   127   127   127
   127   127   127   127
   127   127   127   127
B_correct =
    56    85    85    56
    85   127   127    85
    85   127   127    85
    85   127   127    85
    56    85    85    56
2
Pass
 
%%
A(1,:) = [0:7:63];
A(2,:) = [63:7:127];
A(3,:) = [128:7:191];
A(4,:) = [192:7:256];
A
B_correct = [16 26 30 35 40 44 49 54 58 40; 45 71 78 85 92 99 106 113 120 82; 87 135 142 149 156 163 170 177 184 125; 73 111 116 121 125 130 135 139 144 98]
assert(isequal(med_filt(A),B_correct))
A =
     0     7    14    21    28    35    42    49    56    63
    63    70    77    84    91    98   105   112   119   126
   128   135   142   149   156   163   170   177   184   191
   192   199   206   213   220   227   234   241   248   255
B_correct =
    16    26    30    35    40    44    49    54    58    40
    45    71    78    85    92    99   106   113   120    82
    87   135   142   149   156   163   170   177   184   125
    73   111   116   121   125   130   135   139   144    98
3
Pass
 
%%
clear all
A = [71 128 192 246 215; 174 246 65 140 65; 168 87 130 35 208; 42 150 179 38 62; 30 57 228 66 238]
B_correct = [69 97 113 103 74; 97 140 141 144 101; 96 138 119 102 61; 59 119 108 132 72; 31 76 80 90 45]
assert(isequal(med_filt(A),B_correct))
A =
    71   128   192   246   215
   174   246    65   140    65
   168    87   130    35   208
    42   150   179    38    62
    30    57   228    66   238
B_correct =
    69    97   113   103    74
    97   140   141   144   101
    96   138   119   102    61
    59   119   108   132    72
    31    76    80    90    45