How can i round numbers to multiple of any number?

143 次查看(过去 30 天)
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