function gui_slider

f = figure('Visible', 'off', 'color', 'white', 'Position', ...
    [360, 500, 300, 300]);
minval = 0;
maxval = 5;
slhan = uicontrol('Style', 'slider', 'Position', ...
   [80, 170, 100, 50], ...
   'Min', minval, 'Max', maxval, 'Callback', @callbackfn);
hmintext = uicontrol('Style', 'text', 'Backgroundcolor', 'white', ...
   'Position', [40, 175, 30, 30], 'String', num2str(minval));
hmaxtext = uicontrol('Style', 'text', 'Backgroundcolor', 'white', ...
   'Position', [190, 175, 30, 30], 'String', num2str(maxval));
hsttext = uicontrol('Style', 'text', 'Backgroundcolor', 'white', ...
   'Position', [120, 100, 40, 40], 'Visible', 'off');
set(f, 'Name', 'Slider Example')
movegui(f, 'center')
set(f, 'Visible', 'on');

   function callbackfn(source, eventdata)
       for ii=1:20
           pause(.2)
           num = get(slhan, 'Value');
           set(hsttext, 'Visible', 'on', 'String', num2str(num))
       end
   end
end

