Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Dora de Jong
Dora de Jong am 23 Mär. 2021
Kommentiert: Dora de Jong am 23 Mär. 2021
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.

Akzeptierte Antwort

Adam Danz
Adam Danz am 23 Mär. 2021
Bearbeitet: Adam Danz am 23 Mär. 2021
Use strcmp or strcmpi along with all.
Template:
all(strcmp(a,'B'),1) % for columns
all(strcmp(a,'B'),2) % for rows
  4 Kommentare
Dora de Jong
Dora de Jong am 23 Mär. 2021
Thank you so much!!
Dora de Jong
Dora de Jong am 23 Mär. 2021
Yes you are right I mean rows.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by