title: Setting a specific number of tick marks on MATLAB plot
body: <p>I am trying to figure out how to set a custom number of tick marks on the x-axis of a plot I am creating in MATLAB, but I am not sure if this is possible. I saw <a href="https://stackoverflow.com/questions/12105356/plotting-in-matlab-increase-number-of-divisions-on-xaxis">this question</a> that seems to be asking the same thing, but that answer wasn't helpful since</p>
  
  <pre><code>set(gca,'XTick',tickVector);
  </code></pre>
  
  <p>sets the location of the ticks, not the number of ticks.
  My code is as follows.</p>
  
  <pre><code>rangeBegin = 100000;
  rangeEnd = 200000;
  numberOfXTicks = 5;
  
  plot(data(:, 1));
  xAxisVals = linspace(rangeBegin, rangeEnd, numberOfXTicks);
  %set(gca,'XTick',rangeBegin:rangeEnd); % Doesn't work as expected
  set(gca,'XTickLabel',xAxisVals);
  </code></pre>
  
  <p>So in this example, I am just looking for a way to force MATLAB to create the plot with 5 ticks on the x-axis in order to match the 5 XTickLabels that I have set.</p>
  
  <p>data is an array of doubles that is roughly &lt;3000x1>.</p>
  
  <p>EDIT: I should also add that I want my x-axis values to be from a separate array. The data array shown above corresponds to a time array (not shown...my bad), and each value in the data array has a corresponding value in the time array. Since I am selecting a range from the data array, I want to select the corresponding time values and use those as the x labels. But obviously I do not want 3000 time labels on my x-axis.
  Hopefully this is more clear.</p>