function [cm,xo] = gradopt(fcn,x,io,x0,tmax)
% [cm,xo] = gradopt(fcn,x,io,x0,tmax)
% Minimizes the function fcn by the gradient method.
%
% fcn     :  string defining the cost function.  All parameters of fcn 
%            must be called within the string fcn as x(1), x(2), x(3), ... 
%
% x       :  vector of parameters of fcn.  
%            Although the parameters within fcn are named x(i) the actual 
%            parameter set for this formal x may be an arbitrary named vector.
%            The value of x(io(:)) are arbitrary since they are variied for 
%            optimization.
%
% io      :  vector of indices. The parameters x(io(1)) to x(io(end)) 
%            are variied to find the desired optimum
%
% x0      :  2*n-matrix:
% x0(1,:) :  starting point x(io(:))
% x0(2,:) :  parameter step
%
% tmax    :  at least after tmax seconds the iteration shall stop
