Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 133791

Submitted on 3 Sep 2012 by Binbin Qi

Correct

19Size
Leading solution size is 13.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 

                      

                    
2
Pass
 
%%
A = [1     0     0     0     0;...
     0     1     0     0     0;...
     0     0     1     0     0;...
     0     0     0     1     0;...
     0     0     0     0     1];
B = [0     1     0     0     0;...
     0     0     1     0     0;...
     0     0     0     1     0;...
     0     0     0     0     1;...
     1     0     0     0     0];
 tf_correct = 0;
 assert(isequal(intersection_of_matrices(A,B),tf_correct))

                    
3
Pass
 
%%
A = [1     1     0     0     0;...
     0     1     1     0     0;...
     0     0     1     1     0;...
     0     0     0     1     1;...
     1     0     0     0     1];
B = [0     0     0     0     1;...
     1     0     0     0     0;...
     0     1     0     0     0;...
     0     0     1     0     0;...
     0     0     0     1     0];
 tf_correct = 0;
 assert(isequal(intersection_of_matrices(A,B),tf_correct))

                    
4
Pass
 
%%
A = [1     1     0     0     1;...
     1     1     1     0     0;...
     0     1     1     1     0;...
     0     0     1     1     1;...
     1     0     0     1     1];
B = [0     0     1     0     0;...
     0     0     0     1     0;...
     0     0     0     0     1;...
     1     0     0     0     0;...
     0     1     0     0     0];
tf_correct = 0;
assert(isequal(intersection_of_matrices(A,B),tf_correct))

                    
5
Pass
 
%%
A = [1     1     1     0     1;...
     1     1     1     1     0;...
     0     1     1     1     1;...
     1     0     1     1     1;...
     1     1     0     1     1];
B = [0     1     0     0     0;...
     1     0     0     0     0;...
     0     0     0     0     1;...
     0     0     0     1     0;...
     0     0     1     0     0];
tf_correct = 1;
assert(isequal(intersection_of_matrices(A,B),tf_correct))

                    
6
Pass
 
%%
A = [1     1     0     0     1;...
     1     1     1     0     0;...
     0     1     1     1     0;...
     0     0     1     1     1;...
     1     1     0     1     1];
B = [0     0     1     0     0;...
     0     0     0     1     0;...
     0     0     0     0     1;...
     1     0     0     0     0;...
     0     1     0     0     0];
tf_correct = 1;
assert(isequal(intersection_of_matrices(A,B),tf_correct))