필터 지우기
필터 지우기

How to move decimal to the right?

조회 수: 2 (최근 30일)
Shayma Al Ali
Shayma Al Ali 2021년 10월 4일
댓글: Walter Roberson 2021년 10월 4일
I have a time variable that is supposed to formatted as yymmdd.xxxx where xxxx is the fraction of the day. However, the variable is displayed as y.ymmddxxxxx. How do I move the decimal to the right so its formatted correctly?
  댓글 수: 2
DGM
DGM 2021년 10월 4일
편집: DGM 2021년 10월 4일
If the date is represented as a floating point numeric class, why can't you just multiply it by the appropriate value? -- or are you just looking at the number expressed in scientific notation?
format long
D = 1.1223344444 % assuming the number is as described
D =
1.122334444400000
D = D.*1E5 % the number is now as requested, but it displays in scientific notation
D =
1.122334444400000e+05
fprintf('%.5f\n',D) % display it differently (it's still the same number)
112233.44444
Walter Roberson
Walter Roberson 2021년 10월 4일
Sounds like a floating point time variable... this problem would not happen with datetime objects.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by