title: Undefined function 'max' for input arguments of type 'cell'
body: <p>I'm trying to plot bar chart for input data and to add data labels on each bar, when I run the program I got an error as "Undefined function 'max' for input arguments of type 'cell'." my code is...</p>
  
  <pre><code> data = [3 6 2 ;9 5 1];
  figure; %// Create new figure
  h = bar(data);    %// Create bar plot 
  %// Get the data for all the bars that were plotted
  x = get(h,'XData');
  y = get(h,'YData');
  ygap = 0.1;  %// Specify vertical gap between the bar and label
  ylim([0 12])
  ylimits = get(gca,'YLim');
  
  %// The following two lines have minor tweaks from the original answer
  set(gca,'YLim',[ylimits(1),ylimits(2)+0.2*max(y)]);
  labels = cellstr(num2str(data'))                                   %//'
  
  for i = 1:length(x) %// Loop over each bar
      xpos = x(i);        %// Set x position for the text label
      ypos = y(i) + ygap; %// Set y position, including gap
      htext = text(xpos,ypos,labels{i});          %// Add text label
      set(htext,'VerticalAlignment','bottom', 'HorizontalAlignment','center')
  end
  </code></pre>
  
  <p><strong>when I give input as "data = [3 6 2 9 5 1]", the program runs fine</strong></p>