how to find common values in two matrix for particular column?
Mostra commenti meno recenti
if true
% code
A=[0 1 1 0; 1 0 0 1; 1 1 0 0; 0 0 1 1]
B=[0 1 0 1; 1 0 1 0; 0 0 1 1; 1 1 0 0]
end
for 1st column of A and ALL columns of b
if we check
the expected answer is
1 0 2 1
these are the total number of instances they are matching
3 Commenti
madhan ravi
il 24 Ott 2018
1 0 2 1 explain the logic please
Bruno Luong
il 24 Ott 2018
Please put care on
- code formatting
- explanation
- formulation of synthetic question (Why give the whole A and ask just result that depends only on first column)
Shubham Mohan Tatpalliwar
il 24 Ott 2018
Risposta accettata
Più risposte (1)
Stephen23
il 24 Ott 2018
You don't need to use a loop:
>> sum(permute(A,[3,2,1])&permute(B,[2,3,1]),3)
ans =
1 0 1 2
0 1 2 1
2 1 0 1
1 2 1 0
1 Commento
Shubham Mohan Tatpalliwar
il 24 Ott 2018
Categorie
Scopri di più su Shifting and Sorting Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!