extracting character from a string
33 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
DGM
2021-3-27
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!