Loop Question with divison
Show older comments
I have the number 0.357. I want to multiply the number by 2 until it gets to a whole number. Once it gets to a whole number I want to subtract the whole number from 1 and then multiply by 2 until it becomes a whole number again. And I would like this to happen a specific number of times also.
- This what I am trying to get my code to do. (Below)
0.357 *2 = 0.714
0.714 * 2 = 1.428
0.428 * 2 = 0.856
0.856 * 2 = 1.712
0.712 * 2 = 1.424
Thanks
2 Comments
James Tursa
on 20 Feb 2016
What have you done so far? Do you know how to program a for loop? Do you know how to program an infinite while loop?
WhatIsMatlab-
on 20 Feb 2016
Edited: WhatIsMatlab-
on 20 Feb 2016
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!