Converting Cell Array Output to Logical Matrix
Afficher commentaires plus anciens
I have an array output consisting of the following characters: "A1a", "A1b", "A2a", "A2b" for e.g.:
'A1a' 'A2a'
'A1a' 'A2b'
'A1b' 'A2a'
'A1b' 'A2b'
How do I convert it to a logical matrix such that, if the output contains the character "A1a", under the column "A1a", the value will be true" i.e. "1" ?
%Output
Row A1a A1b A2a A2b
1 1 0 1 0
2 1 0 0 1
3 0 1 1 0
4 0 1 0 1
Réponse acceptée
Plus de réponses (1)
out = cellfun(@(x)(strcmp(x,'A1a')), A); % A is the input cell array
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!