Dealing with weird Data in Cell Array

5 views (last 30 days)
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

Accepted Answer

Matt Fig
Matt Fig on 18 May 2011
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 Comments
Matt Fig
Matt Fig on 18 May 2011
Thanks Walter, nice catch.
Aaron
Aaron on 18 May 2011
This works great. Thank you both!

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!