Cody

# Problem 42351. Average valid values of arrays

Solution 1561958

Submitted on 16 Jun 2018
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
x = 1; minV = -10; maxV = 10; y_correct = 1; assert(isequal(round(validAverage(x,minV, maxV),4),y_correct))

2   Fail
x = [-1 -5.4 14.6 20.9 25.5 -22.4 18 15.5 -33.7 -38.1]; minV = -10; maxV = 10; y_correct = -3.2; assert(isequal(round(validAverage(x,minV, maxV),4),y_correct))

Operands to the || and && operators must be convertible to logical scalar values. Error in validAverage (line 2) x = x(x >= minV && x <= maxV); Error in Test2 (line 5) assert(isequal(round(validAverage(x,minV, maxV),4),y_correct))

3   Fail
x=1:100; minV=20; maxV=80; y_correct = 50; assert(isequal(round(validAverage(x,minV, maxV),4),y_correct))

Operands to the || and && operators must be convertible to logical scalar values. Error in validAverage (line 2) x = x(x >= minV && x <= maxV); Error in Test3 (line 5) assert(isequal(round(validAverage(x,minV, maxV),4),y_correct))