How can i round numbers to multiple of any number?

143 vues (au cours des 30 derniers jours)
Volkan Yangin
Volkan Yangin le 7 Avr 2017
Commenté : Volkan Yangin le 7 Avr 2017
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)?

Réponse acceptée

Stephen23
Stephen23 le 7 Avr 2017
Modifié(e) : Stephen23 le 7 Avr 2017
>> V = [9,13,18,25,34];
>> N = 8;
>> N*floor(V/N)
ans =
8 8 16 24 32

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by