extracting character from a string

27 visualizaciones (últimos 30 días)
Uwaiz Dhuny
Uwaiz Dhuny el 27 de Mzo. de 2021
Comentada: Uwaiz Dhuny el 27 de Mzo. de 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.

Respuesta aceptada

DGM
DGM el 27 de Mzo. de 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

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by