# Identify index of cell based on stringlength

1 vue (au cours des 30 derniers jours)
chlor thanks le 4 Mai 2021
Commenté : chlor thanks le 4 Mai 2021
I have a cell array of such:
TStr =
1×1 cell array
{2×1 cell}
TStr{1}(1) =
1×1 cell array
{'Hello... It me, I was wondering if after all these years youd like to meet'}
TStr{1}(2) =
1×1 cell array
{'1800'}
I know that
strlength(TStr{1}(2))
= 4
How do I use this information to identify the index of the cell (in this case, index = 2) with stringlength of 4?
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Turlough Hughes le 4 Mai 2021
Example data:
Tstr{1}{1,1} = 'Hello... It me, I was wondering if after all these years youd like to meet';
Tstr{1}{2,1} = '1800';
You can get the index by:
idx = cellfun(@numel,Tstr{1})==4;
Which gives:
Tstr{1}{idx}
ans = '1800'
##### 4 commentairesAfficher 3 commentaires plus anciensMasquer 3 commentaires plus anciens
chlor thanks le 4 Mai 2021
Oh I see! Thank you very much for your help!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Matrices and 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