MATLAB: How to find cube root using while loop

MATLABwhile loop

In the attached document, how would you write a while loop to display the cube root as it asks. Im more familiar with for loops, so is the while loop the same way? Im just confused how to output the cube root. Im starting off with input statements; not sure if im on the right track?

Best Answer

for K = 1 : 5
something
end
is nearly the same thing as
K = 1
while K <= 5
something
K = K + 1;
end
But sometimes you do not need to count. For example,
err = inf;
while abs(err) > 0.1
some calculation
err = something
end