A while loop is a construction of the form
while condition, program, end
Here condition is a MATLAB functionm, as with the branching construction. The program program will execute successively as long as the vlaue of condition is not 0. Here is a sample program.
function l=twolog(n) % l=twolog(n). l is the floor of % the base 2 logarithm of n. l=0; m=2; while m<=n l=l+1; m=2*m; end