Want to find a specific column of needed data

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
Stalin Samuel 2015년 11월 18일

0 개 추천

[r c] = find(ismember(B(:,1), S, 'rows'))

댓글 수: 1

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.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Meghana Dinesh
Meghana Dinesh 2015년 11월 18일
편집: Meghana Dinesh 2015년 11월 18일

0 개 추천

Have you tried using ismember? I believe you can use a combination of MATLAB functions find and ismember.
find(ismember(M,X),dim)

댓글 수: 1

The "dim" should be columns. So you can take a transpose of your matrix.

댓글을 달려면 로그인하십시오.

Prashant Funde
Prashant Funde 2015년 11월 18일

0 개 추천

need to take transpose of B as well as S to get proper answer.
Thanks for your support..

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2015년 11월 18일

답변:

2015년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by