How can I access char elements from the beginning up to some fixed index of the char?
1 次查看(过去 30 天)
显示 更早的评论
a = char(abdefghijk);
I want the output 'abcdefg'
0 个评论
采纳的回答
更多回答(2 个)
Vikram Ojha
2022-12-7
编辑:Vikram Ojha
2022-12-7
>> a='abcdefghijk'
>> a(1:5)
ans =
'abcde'
In genral a(1:n) % n for index
You can consider going through following doc: https://in.mathworks.com/help/matlab/ref/string.html, it will be helpful
In case you want you can take Matlab fundamental certification: https://matlabacademy.mathworks.com/details/matlab-fundamentals/mlbe
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!