How can i round numbers to multiple of any number?

조회 수: 135 (최근 30일)
Volkan Yangin
Volkan Yangin 2017년 4월 7일
댓글: Volkan Yangin 2017년 4월 7일
Hi everbody
There are commands for rounding of numbers in MATLAB like ceil, floor etc., but if we should round the numbers to multiple of any number (toward negative infinity), what kind of a code can be written?
For ex. multiples of 8: 8, 16, 24, 32...
Numbers: 9, 13,18, 25,34...
Results: 8, 8, 16, 24, 32...
Is there any code for round these numbers to multiple of 8 (toward negative infinity)?

채택된 답변

Stephen23
Stephen23 2017년 4월 7일
편집: Stephen23 2017년 4월 7일
>> V = [9,13,18,25,34];
>> N = 8;
>> N*floor(V/N)
ans =
8 8 16 24 32

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by