title: Why Matlab shows "Index exceeds matrix dimensions."?
body: <p>Here is my matlab code:</p>
  
  <pre><code>gg=imread('fsu_Westcott.jpg');
  data1=gg(:,1);
  histArray1=zeros(1,256);
  x=0:1:255;
  for n=1:length(data1)
  histArray1(1,data1(n)+1)=histArray1(1,data1(n)+1)+1;
  end
  for n=1:length(data1)
  number1=sum(histArray1(1:n));
  end
  plot(x,number1,'r')
  </code></pre>
  
  <p>Why it shows "Index exceeds matrix dimensions."? before I finally plot? I am new and thanks in advance! :)</p>