Effacer les filtres
Effacer les filtres

Retrieve Both Besides String of Center String

1 vue (au cours des 30 derniers jours)
Angga Lisdiyanto
Angga Lisdiyanto le 29 Juin 2016
Commenté : José-Luis le 30 Juin 2016
Hi, i want to retrieve both string of center string. In example, i have below data :
data = {'a', 'b', 'c', 'o', 'm'}
center_string = {'c'}
Output
'b' 'o'
or
'b' 'c' 'o'
Thanks in advance.

Réponse acceptée

José-Luis
José-Luis le 29 Juin 2016
Modifié(e) : José-Luis le 29 Juin 2016
data = {'a', 'b', 'c', 'o', 'm'};
idx = find(~cellfun(@isempty,strfind(data,'o')));
your_result = data(idx-1:idx+1)
  2 commentaires
Angga Lisdiyanto
Angga Lisdiyanto le 29 Juin 2016
Thanks.
By the way, what is difference of ~cellfun with cellfun?
José-Luis
José-Luis le 30 Juin 2016
~ is the NOT operator.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by