Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Adam Danz
Adam Danz il 23 Mar 2021
Modificato: Adam Danz il 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 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by