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 187485

Submitted on 7 Jan 2013

Incorrect

233Size
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
Test_Matrix =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0   127   127   127   127     0     0
     0     0   127   127   127   127     0     0
     0     0   127   127   127   127     0     0
     0     0   127   127   127   127     0     0
     0     0   127   127   127   127     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
Test_Matrix =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0    56    77    79    51     0     0
     0     0    71   102   105    68     0     0
     0     0    76   110   113    74     0     0
     0     0    77   112   116    76     0     0
     0     0    49    68    70    43     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
B =
    56    85    85    56
    85   127   127    85
    85   127   127    85
    85   127   127    85
    56    85    85    56
2
Fail
 
%%
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))
Error: Assertion failed.
3
Fail
 
%%
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))
Error: Assertion failed.