Cody

# Problem 44698. how many of the entries are positive?

Solution 1585219

Submitted on 17 Jul 2018 by Alekhya Makineni
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(pos(sin(linspace(0,10*pi,100))),49))

count_logic = 1×100 logical array Columns 1 through 44 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 Columns 45 through 88 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Columns 89 through 100 1 1 0 0 0 0 0 0 0 0 0 0 count = 49

2   Pass
assert(isequal(pos(sin(linspace(0,2*pi,100))),49))

count_logic = 1×100 logical array Columns 1 through 44 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 45 through 88 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 100 0 0 0 0 0 0 0 0 0 0 0 0 count = 49

3   Pass
assert(isequal(pos(-10:10),10))

count_logic = 1×21 logical array 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 count = 10

4   Pass
x=NaN(1,10) assert(isequal(pos(x),0))

x = NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN count_logic = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 count = 0

5   Pass
x=[NaN(1,10) -10:10] assert(isequal(pos(x),10))

x = Columns 1 through 29 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 Columns 30 through 31 9 10 count_logic = 1×31 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 count = 10