logic vector given two string arrays?
Afficher commentaires plus anciens
I am given 2 char arrays, let's call them A and B, A has constant dimensions and values and B varies in both.
I am trying to get a logic vector of all zeros and ones in a single column. for each row of the column I need the value to be one i the array in row one of A contains any of the strings in array B.
For example,
A=
'hello'
'world'
'this '
'is '
'an '
'examp'
'le '
and
B=
'is'
'he'
So the return would be
'1'
'0'
'1'
'1'
'0'
'0'
'0'
How would I write this to give it back in this form?
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 21 Fév 2018
reshape( char('0' + ismember(cellstr(A), cellstr(B))), [], 1)
Catégories
En savoir plus sur Resizing and Reshaping Matrices 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!