extracting character from a string

33 vues (au cours des 30 derniers jours)
Uwaiz Dhuny
Uwaiz Dhuny le 27 Mar 2021
Commenté : Uwaiz Dhuny le 27 Mar 2021
hi,
i want to know how to extract a character from a string, for example if my string is MATLABQUESTION, i want the fifth letter only.

Réponse acceptée

DGM
DGM le 27 Mar 2021
If you only want the n-th character, then it's simple:
mystring='MATLABQUESTION';
fifthchar=mystring(5)
which would be:
fifthchar =
A
And of course, you could do a range:
substring=mystring(7:11)
to get
substring =
QUEST
  1 commentaire
Uwaiz Dhuny
Uwaiz Dhuny le 27 Mar 2021
thanks it works

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by