Cody

Problem 367. Specific Element Count

Solution 2624023

Submitted on 28 Jun 2020 by Ramesh Kumar V
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
assert(isequal(ecount(1:10,2),1))

b = 1×10 logical array 0 1 0 0 0 0 0 0 0 0

2   Pass
assert(isequal(ecount([1 1 1 1 1 1 1 1],1),8))

b = 1×8 logical array 1 1 1 1 1 1 1 1

3   Pass
assert(isequal(ecount([1 1 1 1 1 1 1 1],2),0))

b = 1×8 logical array 0 0 0 0 0 0 0 0

4   Pass
assert(isequal(ecount([1 1 1 1 NaN NaN 1 1],NaN),2))

5   Pass
assert(isequal(ecount([1 1 1 1 NaN NaN 1 1],17),0))

b = 1×8 logical array 0 0 0 0 0 0 0 0

6   Pass
assert(isequal(ecount([15 13 6 2 71 -5 -7 15],15),2))

b = 1×8 logical array 1 0 0 0 0 0 0 1

Suggested Problems

More from this Author56

Community Treasure Hunt

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

Start Hunting!