Cody

# Problem 44509. Determine if input is a valid AHP evaluation matrix

Solution 2504417

Submitted on 9 Jun 2020 by Luca Fenzi
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 1 1 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

2   Pass
x = [1 2 1/2 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

3   Pass
k = randi([2 9]); x = [1 k 1/k 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

4   Pass
k = randi([2 9]); x = [1 k 1/k k]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 0

5   Pass
x = [1 5 1/5 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

6   Pass
x = [1 4 1/4 2]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 0

7   Pass
x = [1 1 1 1 1 1 1 1 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

8   Pass
x = [1 2 3 1/2 1 4 1/3 1/4 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

9   Pass
x = [1 2 3 1/2 0 4 1/3 1/4 1]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 0

10   Pass
x = [1 1 1 1 1 1 1 1 0.5]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 0

11   Pass
x = [1 1 95 1 1 1 1 1 1]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 0

12   Pass
x = [1 2 2 1/2 1 2 1/2 1/2 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

13   Pass
m = randi([2 5]); x = [1 m m 1/m 1 m 1/m 1/m 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

14   Pass
x = [1 2 3 4 1/2 1 5 6 1/3 1/5 1 7 1/4 1/6 1/7 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

15   Pass
x = [0 2 3 4 1/2 0 5 6 1/3 1/5 0 7 1/4 1/6 1/7 0]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 0

16   Pass
x = [1 1 1 1 1 1 1 1 1 1 1 1 ]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0

17   Pass
x = [1 1 1 1 1 1 1 1 1 1 1 1 ]; y_correct = 0; assert(isequal(isValidAHP(x),y_correct))

y = logical 0

18   Pass
x = [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]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

19   Pass
x = [1 0.125 0.125 0.111 0.125 0.125; 8 1 1 0.143 0.143 0.2; 8 1 1 0.111 0.111 0.143; 9 7 9 1 5 7; 8 7 9 0.2 1 0.333; 8 5 7 0.143 3 1]; y_correct = 1; assert(isequal(isValidAHP(x),y_correct))

y = logical 0 y = 1

20   Pass
for idx = 1:20 x = ones(randi([1 20])); y_correct = 1; assert(isequal(isValidAHP(x),y_correct)) end

y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1 y = logical 0 y = 1

21   Pass
for idx = 1:20 x = zeros(randi([1 20])); y_correct = 0; assert(isequal(isValidAHP(x),y_correct)) end

y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0 y = logical 0 y = 0

### Community Treasure Hunt

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

Start Hunting!