Exercise 6.8: WHILE loop

Make a function file `divide.m'.

This function must divide a number $ x$ by 2 till the new obtained number is smaller than 2.

Input of the function file:
-
$ x$ : An arbitrary number.
Output of the function file:
-
$ p$ : A number that represents how often the number $ x$ is divided by 2.
-
$ q$ : The value that is left when the number $ x$ is divided by 2, $ p$ times.
a)
Work out the problem on paper.
b)
Write the m-file in MATLAB.



Previous      Next      Up      Answer


Esteur 2010-03-22