フィルターのクリア

Extracting character before point (.)

2 ビュー (過去 30 日間)
Gokhan Kayan
Gokhan Kayan 2018 年 1 月 30 日
コメント済み: Gokhan Kayan 2018 年 1 月 30 日
I have an character array (7879X1) and I want to extract character just before the point '.'For example my first 6 characters are given below and I want to pull just one character before point.
KT2.5FDR
CB6.456
DFRG8.9B
D6.GFDE8
CBNGD9.FD
CVDF8.BDF
So I should have a new cell array that consist of
2
6
8
6
9
8
How can I do this ? Thanks for your reply.

採用された回答

Stephen23
Stephen23 2018 年 1 月 30 日
編集済み: Stephen23 2018 年 1 月 30 日
This is easy using regexp:
>> C = {'KT2.5FDR';'CB6.456';'DFRG8.9B';'D6.GFDE8';'CBNGD9.FD';'CVDF8.BDF'};
>> D = regexp(C,'\d(?=\.)','match','once');
>> D{:}
ans = 2
ans = 6
ans = 8
ans = 6
ans = 9
ans = 8
These characters are easy to convert to numeric:
>> V = str2double(D)
V =
2
6
8
6
9
8
  1 件のコメント
Gokhan Kayan
Gokhan Kayan 2018 年 1 月 30 日
Oh it really helps me, thank you mate :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by