フィルターのクリア

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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by