Find Common elements between any two columns in each matrix

3 views (last 30 days)
I'm comparing two matrices: 'KeyNeuronMat1', 100x12 and 'KeyNeuronMat2', 100x9. Each row in the matrix represents a neuron # drawn from a 100 total neurons and each column represents a group # computed by different NN so if a neuron gets assigned to that group, it is given a value "1", else "0". For each column in 'KeyNeuronMat1' (sample below), I'd like to identify which neurons (row indicies)
>> keyNeuronMat1(1:10,1:4)
ans =
1 1 1 1
0 0 0 0
0 1 0 0
0 1 1 1
1 0 0 0
0 0 0 0
0 1 0 0
0 1 0 0
0 0 1 1
0 0 1 1
are in common within each of the groups (e.g. column indicies) in 'KeyNeuronMat2' without using a loop.
>> keyNeuronMat2(1:10,5:8)
ans =
1 0 0 0
1 1 1 1
0 1 0 0
0 0 0 0
1 0 0 0
0 0 0 0
0 0 1 0
0 0 0 0
1 0 0 0
0 0 0 0
Is this possible with bsxfun as I've read about this function being used for similar but was not sure.
I've attached my data.
Thanks for any advice.

Accepted Answer

Bruno Luong
Bruno Luong on 16 Sep 2019
Not sure but
keyNeuronMat1(1:10,1:4) & keyNeuronMat2(1:10,5:8)
Give you common neurons/groups.

More Answers (0)

Categories

Find more on MATLAB Parallel Server in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!