> How can I change the color bar range for this code. I would like to have some how like Levels of [1:2:10]
This question is unclear and can be interpretted in several ways.
To change the color range use caxis().
To create a discrete colormap you've got several options.
If you only want n discrete colors you can use any of the colormap functions and specify the number of levels.
You can combine that with caxis to define when the discrete colors change. For example,
To create a discrete colormap that indicates ranges of x-values of a scatter plot, you need to set the color input to scatter defined by the discrete ranges of x-values.
edges = min(x):2:max(x)+1;
c = discretize(x, edges);