convert char to double
34 次查看(过去 30 天)
显示 更早的评论
var = '0' (this is char)
and i want this value convert 'double'
so i used
out = str2double(regexp(var,'\d*','match')
But I have a parse error
How can I get the val value in double?
For reference, if str2double is used, the NAN value is obtained.
1 个评论
回答(1 个)
Davide Masiello
2022-9-27
编辑:Davide Masiello
2022-9-27
var = '0';
out = str2double(var)
whos out
No need to use regular expressions at all, at least in Matlab.
3 个评论
Davide Masiello
2022-9-27
What you see in my answer is obtained running Matlab R2022b.
What version do you use?
另请参阅
类别
在 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!