convert string to number or array

8 views (last 30 days)
TTA
TTA on 8 Oct 2019
Answered: the cyclist on 8 Oct 2019
Please I want to convert this array to an array. if I use str2double I obtain those starting 0.something as NAN.
please help
' 0. 9'
' 0. 9'
' 1. 2'
' 1. 4'
' 1.14'
' 1.39'
' 1.42'
' 1.45'
' 1.46'
' 1.59'
' 2.28'
' 2.34'
' 2.43'
' 3.18'
' 3.35'
' 4.10'
' 4.48'
'11.24'
'11.33'
'11.33'
'12.13'
'12.32'
'12.54'
'13. 2'
'13. 5'
'13. 9'
'13.13'
'13.13'
'13.22'
'13.22'
'13.50'
'13.57'
'14.16'
'14.19'
'14.41'
'14.42'
'14.44'
'14.46'
'14.48'
'14.53'
'14.53'
'14.57'
'15.33'
'15.33'
'15.59'
'16. 6'
'16.10'
'16.12'
'16.14'
'16.19'
'16.27'
'16.37'
'16.37'
'17. 7'
'17.14'
'17.27'
'17.40'
'17.47'
'17.51'
'18. 4'
'18. 4'
'21.26'
'21.26'
'21.29'
'23.10'
'23.18'
'23.44'
'23.48'
'23.57'

Accepted Answer

the cyclist
the cyclist on 8 Oct 2019
I'm guessing it's the space that is causing the problem. Run your array through
x = regexprep(x,' ','');
first to remove the spaces.

More Answers (0)

Categories

Find more on Data Type Conversion 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!