function tlb=f_ticklabel(t,tl)
% F_TICKLABEL return a char array of the tick labels
% for labeling the tick marks along the respective axis.
%
% tlb  is a char array of tick labels;
% t    is a vector of tick marks along the respective axis;
% tl   is a vector, or scalar, or cell array.
%  1. tl is a vector.
%     Only the ticks represented in a vector tl will be labeled.
%     To get a single label of the n value use the vector [n n];
%  2. tl is a scalar.
%     Every tl-th tick will be labeled;
%  3. tl is an array of string cells.
%     Ticks will be labeled with the strings containing in the array.
%     Array tl size and vector t size must be equal.
%
%  EXAMPLE:
%      t=[0:2:10];
%      for i=1:3
%         switch i
%         case 1
%            tl=[0 4 10];
%         case 2
%            tl=2;
%         case 3
%            tl=[{'a0'},{'a1'},{' '},{'a3'},{'a4'},{'a5'}];
%         end
%         subplot(1,3,i);
%         plot(2:8,(2:8).^3,'-o');
%         axis([0 10 -inf inf]);
%         set(gca,'xtick',t);
%         tlb=f_ticklabel(t,tl);
%         set(gca,'xticklabel',tlb);
%      end 
% Written by: Olga I. Kosnyreva (Oct 2003), AOPE WHOI

if nargin==0 |  nargin==1
   disp('No arguments');
   return;
end

needTick=t;
needTickLabel=tl;

if size(needTick,1)>1 & size(needTick,2)>1
   disp(strvcat('t must be a vector or scalar',' '));
   tickLabels=[];
   return;
end
if size(needTickLabel,1)>1 & size(needTickLabel,2)>1
   disp(strvcat('tl must be a vector, or scalar, or 1-dimensional cell array',' '));
   tickLabels=[];
   return;
end

if isnumeric(needTickLabel)
   tickLabels=num2str(needTick(1));
   for j=2:1:length(needTick)
      tickLabels=strvcat(tickLabels,num2str(needTick(j)));
   end
   if length(needTickLabel)==1, ...
         needTickLabel=needTick([1:needTickLabel:end]); end
   countTick=0;
   for tickValue=[needTick]
      countTick = countTick+1;
      elNum=find(needTickLabel(:)==tickValue);
      if isempty(elNum), ...
            tickLabels(countTick,1:size(tickLabels,2))=' '; end
   end
elseif iscell(needTickLabel)
   if size(needTickLabel,2)==size(needTick,2)
      tickLabels=[];
      for i=1:length(needTick)
         lbl_i=needTickLabel{i};
         tickLabels=strvcat(tickLabels,lbl_i);
      end
   else
      disp(strvcat('Cell array of tick labels and vector of tick values must have same size',' '));
      tickLabels=[];
      return;
   end
else
   disp(strvcat('Wrong input',' '));
   return;
   tickLabels=[];
end
tlb=tickLabels;