Dealing with weird Data in Cell Array

I have the following data that is random throught a cell array. I need to remove the second decimal point on some of the data
LOLS Purge Supply - Standby.
GHe-W Supply - Standby.
0.000320.
42.9333
42.9333
So in this example I need 0.000320. to be equal 0.000320 so I can later plot this data. How do I remove the second decimal point on the data that has 2 decimal points?
Please any help would be greatly appreciated. -Aaron

 採用された回答

Matt Fig
Matt Fig 2011 年 5 月 18 日

0 投票

C = {'LOLS Purge Supply - Standby.';'GHe-W Supply - Standby.';'0.000320.';'42.9333';'42.9333'}
D = regexprep(C,'\d\.$','')
EDIT Thanks to Walter for catching my error.
That last line should be:
D = regexprep(C,'(?<=\d)\.$','') % Use look-behind!

3 件のコメント

Walter Roberson
Walter Roberson 2011 年 5 月 18 日
No quite.
D = regexprep(C,'(?<=\d)\.$','');
Otherwise you delete the digit before the period.
Matt Fig
Matt Fig 2011 年 5 月 18 日
Thanks Walter, nice catch.
Aaron
Aaron 2011 年 5 月 18 日
This works great. Thank you both!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

2011 年 5 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by