extracting character from a string

33 visualizzazioni (ultimi 30 giorni)
Uwaiz Dhuny
Uwaiz Dhuny il 27 Mar 2021
Commentato: Uwaiz Dhuny il 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.

Risposta accettata

DGM
DGM il 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

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by