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 123373

Submitted on 3 Aug 2012

Incorrect

78Size
Leading solution size is 38.
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
 
%%
f = fopen('mymorphop.m','rt');
code = lower(fread(f,Inf,'*char'))';
fclose(f);
assert(isempty(strfind(code,'dilat')))
assert(isempty(strfind(code,'erode')))
assert(isempty(strfind(code,'bwmorph')))
assert(isempty(strfind(code,'filt')))
assert(isempty(strfind(code,'conv')))

                    
2
Pass
 
%%
in = zeros(3,3);
out = in;
assert(isequal(mymorphop(in),out));

                    
3
Fail
 
%%
in = zeros(10,5);
in(4,3) = 1;
out = in;
out(3:5,2:4) = 1;
assert(isequal(mymorphop(in),out));
Error: Assertion failed.
4
Fail
 
%%
in =  [0,0,1,0,0,1,0
       0,1,0,0,0,1,1
       1,1,0,0,0,0,0
       1,0,0,0,0,0,1
       1,0,0,0,0,1,1];
out = [1,1,1,1,1,1,1
       1,1,1,1,1,1,1
       1,1,1,0,1,1,1
       1,1,1,0,1,1,1
       1,1,0,0,1,1,1];
assert(isequal(mymorphop(in),out));
Error: Assertion failed.
5
Fail
 
%%
in =  [0,0,1,0,0,0,0,0,1
       0,1,0,0,0,0,0,0,1
       1,1,0,0,0,0,0,0,1
       1,0,0,0,0,0,0,0,1
       1,0,0,0,0,0,0,0,1];
out = [1,1,1,1,0,0,0,1,1
       1,1,1,1,0,0,0,1,1
       1,1,1,0,0,0,0,1,1
       1,1,1,0,0,0,0,1,1
       1,1,0,0,0,0,0,1,1];
assert(isequal(mymorphop(in),out));
Error: Assertion failed.