extracting character from a string

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.

 Accepted Answer

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

More Answers (0)

Categories

Products

Release

R2020b

Asked:

on 27 Mar 2021

Commented:

on 27 Mar 2021

Community Treasure Hunt

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

Start Hunting!