function stindex=set_startindex(yy,dir)
%
% Setting the start index.
%
% yy : interger number representing yy-th optimization of x and y.
% dir: the direction which you want to optimize.

if(nargin~=2)
    narginerror();
end

if(strcmp(dir,'horizontal')==1)
    if(yy==1)
        stindex=yy+1;
    else
        stindex=yy;
    end
elseif(strcmp(dir,'vertical')==1)
    stindex=yy+1;
else
    error('Specify the direction which you want to optimize.\n');
end