How to convert char into double?
Mostrar comentarios más antiguos
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 comentarios
KSSV
el 30 de Sept. de 2016
Your character number got two points?
Jan
el 30 de Sept. de 2016
Which number do you expect as output?
Ivan Shorokhov
el 30 de Sept. de 2016
Respuesta aceptada
Más respuestas (2)
Andrei Bobrov
el 30 de Sept. de 2016
with str2double
out = str2double(regexp(val,'\d*','match'))
5 comentarios
Cheikh Ba SY
el 17 de En. de 2018
Thank you so much! It's very helpful
MOSTEFAI Messaoud
el 19 de Mzo. de 2020
Thank's
mayar elrakhawy
el 26 de Abr. de 2022
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
el 26 de Abr. de 2022
I need the value 43.3414 only
str = 'v: 43.3414 m^3/kg';
a = sscanf(str, 'v: %f')
Whashak Faeid
el 25 de Ag. de 2020
0 votos
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 comentario
Stephen23
el 25 de Ag. de 2020
>> str = '$11.75';
>> val = sscanf(str,'$%f')
val = 11.750
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!