基準値の倍数に....

20 ビュー (過去 30 日間)
Katotyan_pe
Katotyan_pe 2021 年 3 月 19 日
編集済み: Katotyan_pe 2021 年 4 月 9 日
基準値0.3としその倍数

回答 (1 件)

Akira Agata
Akira Agata 2021 年 3 月 19 日
以下のような処理ではいかがでしょうか?
c = 0.3; % 基準値
inValue = 5*rand(10,1); % 切り上げ/切り捨て前の値
outValue = c*round(inValue/c); % 基準値のk倍に切り上げ/切り捨て
以下は実効結果の一例です(左:入力値 / 右:出力値)
>> [inValue, outValue]
ans =
4.0014 3.9000
0.7094 0.6000
2.1088 2.1000
4.5787 4.5000
3.9610 3.9000
4.7975 4.8000
3.2787 3.3000
0.1786 0.3000
4.2456 4.2000
4.6700 4.8000

カテゴリ

Help Center および File ExchangeSimulink Function についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!