필터 지우기
필터 지우기

Index of the colums which contains only specific char 'B'

조회 수: 1 (최근 30일)
Dora de Jong
Dora de Jong 2021년 3월 23일
댓글: Dora de Jong 2021년 3월 23일
Cell array values and words.
Want to find which colums contains only B's
a = {
1 'B' 2 'B' ;
'B' 'B' 'B' 'B' ;
1 2 'B' 'A';
}
Wanted outcome:
b =[0;1;0]
This is a simplified version of the entire array a.

채택된 답변

Adam Danz
Adam Danz 2021년 3월 23일
편집: Adam Danz 2021년 3월 23일
Use strcmp or strcmpi along with all.
Template:
all(strcmp(a,'B'),1) % for columns
all(strcmp(a,'B'),2) % for rows
  댓글 수: 4
Dora de Jong
Dora de Jong 2021년 3월 23일
Thank you so much!!
Dora de Jong
Dora de Jong 2021년 3월 23일
Yes you are right I mean rows.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by