# Want to find a specific column of needed data

52 views (last 30 days)
Prashant Funde on 18 Nov 2015
Answered: Prashant Funde on 18 Nov 2015
I have a matrix of B= [ ]4*25 data bits, and i have another variable which consist of one of the column of B. How can i find specific column with its number?
e.g. B=[1 1 0 1; 1 1 1 0;..........0 1 1 1]; and i want to find S=[1 0 1 1] in B.

Stalin Samuel on 18 Nov 2015
[r c] = find(ismember(B(:,1), S, 'rows'))
Prashant Funde on 18 Nov 2015
i got this answer when i tried above method: r =
1
2
3
4
c =
1
1
1
1
but if i know only column number then also its fine... Its expected that find S in B without using for loop.

Meghana Dinesh on 18 Nov 2015
Edited: Meghana Dinesh on 18 Nov 2015
Have you tried using ismember? I believe you can use a combination of MATLAB functions find and ismember.
find(ismember(M,X),dim)
Meghana Dinesh on 18 Nov 2015
The "dim" should be columns. So you can take a transpose of your matrix.

Prashant Funde on 18 Nov 2015
need to take transpose of B as well as S to get proper answer.