필터 지우기
필터 지우기

Insert comma/point in a number

조회 수: 1 (최근 30일)
Michela Longhi
Michela Longhi 2017년 12월 12일
댓글: Star Strider 2017년 12월 12일
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

채택된 답변

Star Strider
Star Strider 2017년 12월 12일
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
Michela Longhi
Michela Longhi 2017년 12월 12일
exaclty what I immagine! Thanks
Star Strider
Star Strider 2017년 12월 12일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by