How to convert char into double?
显示 更早的评论
Hello everyone,
I have following char: "2.311.592 /" And I want to convert it to double and leave numbers only, I have tried to use
new = str2double(val);
But the output was NaN, what would you recommend me to do?
3 个评论
KSSV
2016-9-30
Your character number got two points?
Jan
2016-9-30
Which number do you expect as output?
Ivan Shorokhov
2016-9-30
采纳的回答
更多回答(2 个)
Andrei Bobrov
2016-9-30
with str2double
out = str2double(regexp(val,'\d*','match'))
5 个评论
Cheikh Ba SY
2018-1-17
Thank you so much! It's very helpful
MOSTEFAI Messaoud
2020-3-19
Thank's
mayar elrakhawy
2022-4-26
I have the following char str= 'v: 43.3414 m^3/kg'
out = str2double(regexp(val,'\d*','match'))
out =
43 3414 3
how could it be converted to double without eleminating the decimal point ?
thanks in advance
mayar elrakhawy
2022-4-26
I need the value 43.3414 only
str = 'v: 43.3414 m^3/kg';
a = sscanf(str, 'v: %f')
Whashak Faeid
2020-8-25
0 个投票
How can I change '$11.75' this data type from char to doube.I want my output $11.75 as a double in data type.
Thanks in advance.
1 个评论
Stephen23
2020-8-25
>> str = '$11.75';
>> val = sscanf(str,'$%f')
val = 11.750
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!