필터 지우기
필터 지우기

Index character in table

조회 수: 1 (최근 30일)
Jeroen Delfos
Jeroen Delfos 2017년 12월 6일
댓글: KL 2017년 12월 6일
In a dataset, I would like to get rid of the letter within the seatnumber on an aircraft: '026C' to 026. For this I am trying to index the first three characters of the string, which I can't get to work.
This is one of the things I tried:
A = cell(1,2);
A{1,1} = '024C';
A{1,2} = '005B';
A(1,1) = A(1,1,1:3)
Can somebody tells me how this indexing works?

채택된 답변

KL
KL 2017년 12월 6일
another way is to use regexprep,
A_new = regexprep(A,'[A-Z]','')
A_new =
1×2 cell array
'024' '005'
  댓글 수: 2
Jeroen Delfos
Jeroen Delfos 2017년 12월 6일
Thank you. I understand this removes any letters [A-Z], instead of the character on the fourth place of the string? I think that is actually what I was searching for.
KL
KL 2017년 12월 6일
Please note that it's case-sensitive. Since you mentioned seat number, I took the liberty to make that assumption.

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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2017년 12월 6일
out = cellfun(@(x)x(1:3),A,'un',0);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by