Info

This question is closed. Reopen it to edit or answer.

Why get i this result?

1 view (last 30 days)
Said BOUREZG
Said BOUREZG on 20 Apr 2017
Closed: MATLAB Answer Bot on 20 Aug 2021
>> 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 Comments
John D'Errico
John D'Errico on 20 Apr 2017
The 1 million'th person to ask this, or an equivalent question.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!