Cody

Problem 2241. Compare two input matrices

Solution 2819767

Submitted on 11 Aug 2020 by Matan Hamburger
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
A=[ 1 2 3 4 5; 5 9 3 0 9] B=[ 1 2 4; 8 9 2] y_correct = 1; assert(isequal(CompareMatrix(A,B),y_correct))

A = 1 2 3 4 5 5 9 3 0 9 B = 1 2 4 8 9 2 x = 1 5 2 9 3 3 4 0 5 9 y = 1 8 2 9 4 2 flag = 1

2   Pass
A=[ 1 2 3 ; 5 9 3 ] B=[ 1 2 4 2; 8 9 2 5] y_correct = 0; assert(isequal(CompareMatrix(A,B),y_correct))

A = 1 2 3 5 9 3 B = 1 2 4 2 8 9 2 5 x = 1 5 2 9 3 3 y = 1 8 2 9 4 2 2 5 flag = 0

3   Pass
A=magic(10) B=magic(7) y_correct = 1; assert(isequal(CompareMatrix(A,B),y_correct))

A = 92 99 1 8 15 67 74 51 58 40 98 80 7 14 16 73 55 57 64 41 4 81 88 20 22 54 56 63 70 47 85 87 19 21 3 60 62 69 71 28 86 93 25 2 9 61 68 75 52 34 17 24 76 83 90 42 49 26 33 65 23 5 82 89 91 48 30 32 39 66 79 6 13 95 97 29 31 38 45 72 10 12 94 96 78 35 37 44 46 53 11 18 100 77 84 36 43 50 27 59 B = 30 39 48 1 10 19 28 38 47 7 9 18 27 29 46 6 8 17 26 35 37 5 14 16 25 34 36 45 13 15 24 33 42 44 4 21 23 32 41 43 3 12 22 31 40 49 2 11 20 x = 92 98 4 85 86 17 23 79 10 11 99 80 81 87 93 24 5 6 12 18 1 7 88 19 25 76 82 13 94 100 8 14 20 21 2 83 89 95 96 77 15 16 22 3 9 90 91 97 78 84 67 73 54 60 61 42 48 29 35 36 74 55 56 62 68 49 30 31 37 43 51 57 63 69 75 26 32 38 44 50 58 64 70 71 52 33 39 45 46 27 40 41 47 28 34 65 66 72 53 59 y = 30 38 46 5 13 21 22 39 47 6 14 15 23 31 48 7 8 16 24 32 40 1 9 17 25 33 41 49 10 18 26 34 42 43 2 19 27 35 36 44 3 11 28 29 37 45 4 12 20 flag = 1

Suggested Problems

More from this Author2

Community Treasure Hunt

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

Start Hunting!