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 =
'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

Steven Lord
Steven Lord 2022년 12월 7일
The extractBefore function will work both for char arrays and strings.

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by