3

I'm having trouble to create a slider for GUI in MATLAB. I really want a slider that ranges from 10^-1 to 10^-5. But that has intervals by factors of 0.1. So the the slider would have a logarithmic scale. Anyone know how to solve this problem?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
milkyway
  • 43
  • 5
  • Welcome to SO. Could you provide an [mcve]? – lhcgeneva Nov 10 '15 at 16:48
  • 3
    The closest you'll be able to come in base MATLAB is to use the linear values of the slider as the powers. Non-linear slider scales aren't available in MATLAB, you'd likely need to dig into the underlying Java to find something. – sco1 Nov 10 '15 at 18:20

1 Answers1

0

I'm not really sure if I understood you right. If you want to make logarithmic scale from linear scale:

Definition of logarithm:

enter image description here

So if you need to slider from 10^-1 to 10^-5 you want to get from your slider some value and convert it properly. I suggest to set your min and max to 1 and 5 (or -5 and -1) and after every slider callback or just use of slider value convert using this equation:

y = 10^(-x)

Where y is your wanted value and x is a value in a slider. In a code it should be similar to this:

logValue = 10^(-get(hObject,'Value'));
set(handles.text2,'string',logValue);

Check this method by putting in your gui some kind of text box that would show you your y.

But if you want to make linear scale from logarithmic:

 y = log(x)