How to compare two matrix?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am having two matrix of sizes 7*7 and 7*1. Now, i need to compare both matrix and entries in one matrix varies based on another matrix. For example, element in fourth row first column of matrix A is 1 and element in first row of matrix B is, so, expected output at matrix C is element 1 in fourth row of first column, whereas remaining terms are 0. Similarly, element in first row of fourth column is 1 in matrix A and fourth entry of matrix B is 0, so output matrix C has 0 element in first row of fourth column. Thank you in advance.
Example:
A=[0 0 0 1 0 0 0
0 1 0 0 0 0 0
0 0 0 0 1 0 0
1 0 0 0 0 0 0
0 0 0 0 0 1 0
0 0 1 0 0 0 0
0 0 0 0 0 0 1]
B=[1; 1; 0; 0; 1; 0; 1]
Expected output:
C=[0 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 0 0 1 0 0
1 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 1]
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!