Moving Decimal Places to the right

조회 수: 14 (최근 30일)
Joydeb Saha
Joydeb Saha 2022년 9월 29일
댓글: Jan 2022년 9월 29일
How can I get the number format as 1412701202.018284 for an exponent format data 1.412701202025964e+09. May be with sprintf "%.6f" or equivalent ? I need to do the task for a mat file I am attaching.
  댓글 수: 2
Jan
Jan 2022년 9월 29일
The number format matters for the text output only. In a comment above you mention, that you want to get a double as output. This is not meaningful. So which problem do you want to solve actually?
Rik
Rik 2022년 9월 29일
@Joydeb Saha You need to first respond to the question Jan raised: what is it you want? Do you want a char or a double as the output? In the first case you need sprintf, in the second case your question does not make sense, as that is just how the data is displayed, not the underlying data itself.
What exactly do you want to achieve?

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

채택된 답변

VBBV
VBBV 2022년 9월 29일
편집: VBBV 2022년 9월 29일
format long % format long option
sprintf('%6f',1.412701202025964e+09)
ans = '1412701202.025964'
  댓글 수: 9
Joydeb Saha
Joydeb Saha 2022년 9월 29일
이동: Rik 2022년 9월 29일
VBBV, Attached the file which I want to be saved in the desired format I wrote
Jan
Jan 2022년 9월 29일
@Joydeb Saha: As said already, you can store the array in the shown format as CHAR array only:
S = sprintf('%6f\n', GTt)
If you want to store it numerically, the format has no meaning. Matlab stores value in the IEEE754 format and you cannot incfluence the location of the decimal point.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by