%% Using fzero to solve falling float problem
%
% Set parameters.

C = 1035*0.25*0.2/2;
mw = 207;
t = 10;
w = 2;

%%
% Now find the root, Try $m_w$ as startig guess.

m = fzero(@(x) fallingfloat(x,mw,C,t,w), mw)

%%
% This yields a wrong answer $(m>m_w)$.
%
% Try different guess.

m = fzero(@(x) fallingfloat(x,mw,C,t,w), mw+5)

%%
% Or, even better, an interval.

m = fzero(@(x) fallingfloat(x,mw,C,t,w), [mw mw+50])

%%
% Now use options to produce more verbose output.
opt = optimset('Display','iter')

m = fzero(@(x) fallingfloat(x,mw,C,t,w), [mw mw+50],opt)

%%
% Note that fzero has optional output arguments as follows.

[m,fval,exitflag,output] = fzero(@(x) fallingfloat(x,mw,C,t,w), [mw mw+50])

%%
% An exitflag = 1 means that the methods was successful. Consult help for
% the meaning of other flags.
%
