フィルターのクリア

Convert part of a string to number

3 ビュー (過去 30 日間)
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis 2018 年 6 月 17 日
Hi all,
I have a set of coordinates imported from excel in string format. I would like to extract them as numbers in order to plot them. Any ideas?
An example of the coordinate cell array is below:
NA_PC = {'32º 32′ 10″ N.' '117º 06′ 11″ W.' ;
'32º 32′ 04″ N.' '117º 07′ 29″ W.' ;
'32º 31′ 39″ N.' '117º 14′ 20″ W.' ;
'32º 33′ 13″ N.' '117º 15′ 50″ W.' ;
'32º 34′ 21″ N.' '117º 22′ 01″ W.' ;
'32º 35′ 23″ N.' '117º 27′ 53″ W.' ;
'32º 37′ 38″ N.' '117º 49′ 34″ W.' ;
'31º 07′ 59″ N.' '118º 36′ 21″ W.' ;
'30º 33′ 25″ N.' '121º 47′ 29″ W.' ;
'31º 46′ 11″ N.' '123º 17′ 22″ W.' ;
'32º 21′ 58″ N.' '123º 50′ 44″ W.' ;
'32º 56′ 39″ N.' '124º 11′ 47″ W.' }
Thanks for your help in advance,
KMT.

採用された回答

Paolo
Paolo 2018 年 6 月 17 日
編集済み: Paolo 2018 年 6 月 17 日
You can use regexp to simply match the digits in your input.
NA = regexp(NA_PC,'\d{2,3}','match')
The expression matches numbers with between 2 and 3 digits.
NA is a 12x2 cell array with the numerical values.
NA{1,1} =
'32' '32' '10'
NA{1,2} =
'117' '06' '11'
... and so on.
  1 件のコメント
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis 2018 年 6 月 17 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by