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 155350

Submitted on 29 Oct 2012 by Evan

Correct

29Size
Leading solution size is 12.
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
 
%%
assert(isequal(ecount(1:10,2),1))
e =
     2
ans =
     1
2
Pass
 
%%
assert(isequal(ecount([1 1 1 1 1 1 1 1],1),8))
e =
     1
ans =
     8
3
Pass
 
%%
assert(isequal(ecount([1 1 1 1 1 1 1 1],2),0))
e =
     2
ans =
     0
4
Pass
 
%%
assert(isequal(ecount([1 1 1 1 NaN NaN 1 1],NaN),2))
e =
   100
ans =
     2
5
Pass
 
%%
assert(isequal(ecount([15 13 6 2 71 -5 -7 15],15),2))
e =
    15
ans =
     2