How can i round numbers to multiple of any number?

137 ビュー (過去 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
  1 件のコメント
Volkan Yangin
Volkan Yangin 2017 年 4 月 7 日
Thank you Stephen Cobeldick

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by