extracting character from a string

31 Ansichten (letzte 30 Tage)
Uwaiz Dhuny
Uwaiz Dhuny am 27 Mär. 2021
Kommentiert: Uwaiz Dhuny am 27 Mär. 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.

Akzeptierte Antwort

DGM
DGM am 27 Mär. 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

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by