clear
global l0 b k m g

echo off

l0 = 5.0;
b = 5.0;
m = 1.0;
g = 10.0;

% Numerical solution.
clf
view(3)
hold on;
tic
ff = zeros(20000,1);
i = 1;
for k = 1:0.1:10
   for l0 = 1:0.2:20
      xz = fzero( 'fun1', 0 );
      ff(i) = fun1( xz );
      i = i + 1;
      if  (sqrt( b^2 + xz^2 ) > l0)
	plot3( k, l0, xz, 'gv' )
      else
	plot3( k, l0, xz, 'c^' )
	xz = fzero( 'fun1', -500 );
	ff(i) = fun1( xz );
	i = i + 1;
	plot3( k, l0, xz, 'b*' )
	xz = fzero( 'fun1', 500 );
	ff(i) = fun1( xz );
	i = i + 1;
	plot3( k, l0, xz, 'r+' )
      end
  end
end
toc
hx = xlabel( 'k [N/m]' );
set( hx, 'fontsize', 14 );
set( hx, 'color', 'r' );

hy = ylabel( 'l_0 [m]' );
set( hy, 'fontsize', 14 );
set( hy, 'color', 'r' );

hz = zlabel( 'x [m]' );
set( hz, 'fontsize', 14 );
set( hz, 'color', 'r' );


h = title( 'Equilibrium position - k, l_0 dependence');

%echo on
get( h )
set( h, 'fontsize', 14 );
set( h, 'color', 'b' );

%echo off
