Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
How to use two sliders logarithmically spaced to update the plot on the same figure as the sliders are moved?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Jan
le 27 Août 2017
Modifié(e) : Jan
le 27 Août 2017
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.
Réponses (0)
Cette question est clôturée.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!