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'


Walter Roberson
Walter Roberson 2022 年 12 月 7 日

その他の回答 (2 件)

Vikram Ojha
Vikram Ojha 2022 年 12 月 7 日
編集済み: Vikram Ojha 2022 年 12 月 7 日
>> a='abcdefghijk'
>> a(1:5)
ans =
In genral a(1:n) % n for index
You can consider going through following doc:, it will be helpful
In case you want you can take Matlab fundamental certification:

Steven Lord
Steven Lord 2022 年 12 月 7 日
The extractBefore function will work both for char arrays and strings.


Help Center および File ExchangeOperators and Elementary Operations についてさらに検索



Community Treasure Hunt

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

Start Hunting!

Translated by