In order to create a slider UIcontrol object that moves to only integer values, we would need to ensure that 1) clicking the arrow keys and 2) dragging the slider, both move the slider to an integer position. The following illustrate how to do this:
1) Clicking the arrow keys
In order to ensure that clicking the arrow keys moves slider one unit, we can set the minimum step size of the slider to be 1/(MaxSliderValue-MinSliderValue). In this particular example, you would set it as 1/15 units. This can be set by using the 'SliderStep' property of the slider object. In the example code, we have set the 'SliderStep' to [1/15 1]. This means that clicking on the left or right arrow would move the slider 1/15 normalized units (or 1 integer value) and clicking the space between the slider and the arrows would move it completely to one side (this is set by the second element of 'SliderStep', which is equal to 1 in this example).
2) Dragging the slider
In order to ensure that dragging the slider moves it to an integer position, we can round off the value pointed by the slider in the callback function, and also set the position of the slider to this rounded off value.
The following example code illustrates this:
sld = uicontrol('Style', 'slider',...
'Position', [0.3 0.48 0.4 0.04],...
'SliderStep', [1/15 1]);
newval = hObject.Value;
newval = round(newval);
set(hObject, 'Value', newval);
disp(['Slider moved to ' num2str(newval)]);
This screenshot shows the generated GUI and the output at the command line after playing around with the slider for a while: