Insert comma/point in a number
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michela Longhi
am 12 Dez. 2017
Kommentiert: Star Strider
am 12 Dez. 2017
I have a temperature data in a char format without comma or point to divide the decimal and I want to insert a point after the second number (staring from the left):
char= 225800 and I want t=22.58
Can someone help me, please?
Thank you
Michela
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Dez. 2017
I am not certain what you are doing.
I assume ‘char’ is a character vector. If so, this will work:
char = '225800';
t = str2double(char)*1E-4 % Double-Precision Numeric
tstr = sprintf('%.2f', t) % Character Array
t =
22.5800
tstr =
'22.58'
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!