Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to use two sliders logarithmically spaced to update the plot on the same figure as the sliders are moved?

1 次查看(过去 30 天)
Hello all, I am facing quite a problem with the usage of sliders. I have created a function which takes two inputs a and b, and accordingly, returns x and y. I plot x and y on a log-log axis to see how the output behaves.
Now I want to create two sliders for a and b spaced logarithmically, so by moving both of the sliders, I can see how the plot changes. I want to update my current figure with the change in a and b through the sliders.
I am at my wit's end on how to solve this problem and I would greatly acknowledge help from the people here.
Thanks, Subharthi
  4 个评论
Jan
Jan 2017-8-27
编辑:Jan 2017-8-27
The slider works with a linear range and steps only, but it is trivial to calculate the exponentional (not logarithm):
uicontrol('Style', 'Slider', 'Min', 0, 'Max', 3, ...
'SliderStep', [0.1, 0.1], ...
'Callback', @SliderCallbackA);
...
function SliderCallbackA(SliderH, EventData)
Value = get(SliderH);
a = 10 ^ Value;
disp(a)
... now do with a what you want:
updateDiagram('a', a);
% And in the other slider callback:
% updateDiagram('b', a);
end
Creating two sliders works exactly as creating one slider, only do it twice. Perhaps you want to share the values of a and b in the handles struct. Search for "share variables between callbacks" in the forum.
You did not provide any code yet, therefore my "updateDiagram" is a bold guess only. Again: Please post, what you have tried so far, such that suggesting the further steps does not require to guess the complete code.

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by