%plot(sin(1:.1:10))

function mLabelTick(AxisName,position,message)

if get(0,'CurrentFigure')
    if get(gcf,'CurrentAxes')

        OldT	= get(gca,[AxisName,'Tick']);
        OldTL   = get(gca,[AxisName,'TickLabel']);

        NewT	= [OldT,position];
        NewTL   = strvcat(OldTL,message);

        AxisLimits = get(gca,[AxisName,'lim']);
        range=max(AxisLimits) - min(AxisLimits);

        IncrementCheck=find(abs(OldT-position)<range*.001);
        if IncrementCheck
            if length(message)<length(NewTL(1,:))
                for i=length(message)+1:length(NewTL(1,:))
                    message(i)=' ';
                end
            end
            NewTL(IncrementCheck,:)=message;
            NewT  = NewT(1:end-1);
            NewTL = NewTL(1:length(NewTL(:,1))-1,:);
        else
            [NewT,index]=sort(NewT);
            ind=find(index==max(index));
            NewTL=strvcat(NewTL(1:ind-1,:),message,NewTL(ind:end-1,:));
        end
% % %         NewTL = StripExtraSpaces(NewTL);
        set(gca,[AxisName,'Tick'],NewT);
        set(gca,[AxisName,'TickLabel'],NewTL);
    else
        fprintf('%s\n','There is no active axis');
    end
else
    fprintf('%s\n','There is no active figure');
end


% % % %strip extra empty spaces from NewTL if any:
% % % function Strippedseq = StripExtraSpaces(seq)
% % % maxfull=zeros(1,length(seq(:,1)));
% % % for i=1:length(seq(:,1))
% % %     foundit=strfind(seq(i,:),' ');
% % %     if isempty(foundit)
% % %         foundit=length(seq(i,:))+1;
% % %     end
% % %     maxfull(i)=min(foundit)-1;
% % % end
% % % Full=max(maxfull);
% % % Strippedseq=seq(:,1:Full);
% % % % Strippedseq
