How to eliminate values after comma, in double value?

조회 수: 15 (최근 30일)
Mira le
Mira le . 2023년 1월 24일
편집: Stephen23 . 2023년 1월 24일
Hi every one,
I have a problem
I have a set of double values
0.2000 0.2862
I want just use 0.2 and 0.2, I don t need zeros after
  댓글 수: 2
Mira le
Mira le 2023년 1월 24일
In my programm , these values are decreased iteratively, so, when it remains 0.2000
the next value will be 0.1999

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

채택된 답변

Stephen23 2023년 1월 24일
A wild guess:
V = [0.2,0.2862]
V = 1×2
0.2000 0.2862
W = fix(V*10)/10
W = 1×2
0.2000 0.2000
  댓글 수: 2
Stephen23 2023년 1월 24일
편집: Stephen23 님. 2023년 1월 24일
"but I need also to remove these zeros the results that I want is 0.2 and 0.2"
Then you need to first answer my question here:
It is certainly possible to display numeric values with a certain number of fractional zeros, or select the number of fractional zeros when converting to text:
N = 0.2
N = 0.2000
S = sprintf('%.1f',N)
S = '0.2'
But so far you have not made it clear if text is what you require.

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

추가 답변 (0개)


Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기





Community Treasure Hunt

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

Start Hunting!

Translated by