str2num and commas
14 次查看(过去 30 天)
显示 更早的评论
Hi. str2num doesn't seem to convert '20,000' to 20E3. Instead, it becomes a vector of 2 elements: 20 and 0. Is there a way around this or should I replace the comma in the string with '' before doing string2num? Thanks!
0 个评论
采纳的回答
Krishna
2011-10-3
I think str2num considers '20' and '000' as two different strings because of the comma. What is the output that you are looking for? if you use str2double it returns 20000 . Hope that serves your purpose.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!