필터 지우기
필터 지우기

how to extract n characters from a string ???

조회 수: 3 (최근 30일)
Dung Le
Dung Le 2016년 5월 8일
댓글: Weird Rando 2016년 5월 8일
I have a dataset including a variable named "code". I format it as type "character".
This variable contains such observations like G4411, H5551, K9878..
Now I want to extract the first character out of every observation.
This means G4411 --> G, H5551 --> H, K9878 --> K
I have also attached the data file at the end of the post!
Could somebody help me with this problem?
Many Thank and best regard!

채택된 답변

Star Strider
Star Strider 2016년 5월 8일
I can get it to work with your example but not your data:
C = {'G4411'; 'H5551'; 'K9878'};
res = regexp(C, '\w','match','once')
res =
'G'
'H'
'K'
When I try to load your data, it crashes my computer.
  댓글 수: 5
Star Strider
Star Strider 2016년 5월 8일
My (our) pleasure!
Weird Rando
Weird Rando 2016년 5월 8일
:)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by