MATLAB: How to merge tow matrix

matlab functionmatrix

if i have tow matrix
A = [ 1 0 1 0 1 and B = [ 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 ] 0 0 1 0 0 ]
i need a function to merge these matrix on a new matrix but in conditions
  • put in C matrix all row in A that have 1
  • put in C matrix all column in B that have 1
the solution will be
C = [ 1 0 1 0 1
0 0 0 0 0
0 0 1 0 0 ]

Best Answer

C=A|B