Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Why get i this result?

1 回表示 (過去 30 日間)
Said BOUREZG
Said BOUREZG 2017 年 4 月 20 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
>> a = [10035.99];
>> k=[100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01];
% i must get b=[100 0 1 1 1 0 0 1 1 2 0 4] but ...see the end.
for i=1:length(k)
b(i)=fix(a/k(i))
a=mod(a,k(i))
end
b =
100
a =
35.9900
b =
100 0
a =
35.9900
b =
100 0 1
a =
15.9900
b =
100 0 1 1
a =
5.9900
b =
100 0 1 1 1
a =
0.9900
b =
100 0 1 1 1 0
a =
0.9900
b =
100 0 1 1 1 0 0
a =
0.9900
b =
100 0 1 1 1 0 0 1
a =
0.4900
b =
100 0 1 1 1 0 0 1 1
a =
0.2400
b =
100 0 1 1 1 0 0 1 1 2
a =
0.0400
b =
100 0 1 1 1 0 0 1 1 2 0
a =
0.0400
b =
100 0 1 1 1 0 0 1 1 2 0 3
a =
0.0100
  2 件のコメント
John D'Errico
John D'Errico 2017 年 4 月 20 日
The 1 million'th person to ask this, or an equivalent question.

回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by