round off to nearest 5 instead of 10

조회 수: 101 (최근 30일)
Ben
Ben 2014년 12월 9일
댓글: John D'Errico 2020년 10월 4일
is that any way to round off to nearest 5 instead of 10? for example, round off 346 to 345; 293 to 295; 296 to 295;
thx for help :p
  댓글 수: 3
Aiman Waheed
Aiman Waheed 2020년 10월 4일
How can I get round nearest tenth in Matlab
John D'Errico
John D'Errico 2020년 10월 4일
@Aiman Waheed:
Use round. READ THE HELP FOR ROUND. Unless you have an old release of MATLAB, round has allowed you to round to any number of digits for some years now.
Note that you cannot round to an EXACT decimal, since MATLAB does not store numbers in a decimal form.

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

채택된 답변

Adam
Adam 2014년 12월 9일
편집: Adam 2014년 12월 9일
round( x / 5 ) * 5;
  댓글 수: 2
Ben
Ben 2014년 12월 9일
thanks!!! why i never think in this way!
Adam
Adam 2014년 12월 9일
Well, it isn't always easy. I asked a question on creating a matrix to which the answer provided by Rick Rosson was similarly trivial a few months ago, but only if your thought process takes you in that direction!

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

추가 답변 (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