MATLAB: Is it possible to create a slider with a logarithmic scale within MATLAB 7.6 (R2008a)

calbackguiguideMATLABslideuicontroluserdata

I would like to create a slider whose value changes on a logarithmic scale, not a linear scale.

Best Answer

The ability to specify a logarithmic scale for a slider is not available in MATLAB 7.6 (R2008a). To implement such a slider, you will need to convert its linear value into a logarithmic value before using it in your GUI.
For example, the following slider has a range of 10^0 to 10^2:
range = [10^0 10^2];
h = uicontrol('style', 'slider', ...
'position', [50 50 200 20],...
'min', log10(range(1)),...
'max', log10(range(2)),...
'callback', @(src,event)set(src,'UserData',10^get(src,'Value')));
To query the value of the slider, now you would need to query its "UserData" property instead of its "Value" property. For example,
get(h, 'UserData')
This slider has a leftmost value of 1 and a rightmost value of 100. Notice how the center value is 10, not 50.