How to compare two matrix?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!