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

1 view (last 30 days)
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.

Accepted Answer

Adam Danz
Adam Danz on 23 Mar 2021
Edited: Adam Danz on 23 Mar 2021
Use strcmp or strcmpi along with all.
Template:
all(strcmp(a,'B'),1) % for columns
all(strcmp(a,'B'),2) % for rows
  4 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Report Generator 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!