pop up menu and slider....
3 次查看(过去 30 天)
显示 更早的评论
Hi all. I am new to GUIDE. I have made a pop up menu with four options. Now i want to make a slider that has values ranging from 5 to 12. What i want to do is if i select Option 1 from Pop up, slider value shall lie between 5 and 6. If Option 2, slider should fall in 7-9 and so on...... please help if anybody has idea how to do it..... Thanks
0 个评论
采纳的回答
Hugo
2013-6-7
编辑:Hugo
2013-6-7
Hopefully this helps:
1) Save the handles of the ui elements. Suppose that hpopup and hslider are the handles of the pop up menu and the slider, respectively.
2) When you define the pop up menu, add in the list of arguments:
...,'Callback',@modslider...
@modslider is a function that will be call whenever you choose a different option in the pop up menu. The name modslider is just a name, you can change it as you wish.
3) Define a function
function modslider(hcall,eventdata)
end
hcall contains the handle of the ui that called it. From there you can get what option is active using
get(hcall,...)
and set the appropriate value of the slider using
set(hslider,...)
Best regards
3 个评论
Hugo
2013-6-7
编辑:Hugo
2013-6-7
I apologise for the misspelling in the name of the function. Now I have corrected it.
The function can be a nested function, or in a different file, as long as matlab can find it.
It should be something like this
function modslider(hcall,eventdata)
valpopup=get(hcall,...); %here you get the value of the property of the pop up menu, be it the index of the chosen item or anything else.
switch valpopup
case ...: set(hslider,....); % here you set the value of the slider that you want to modify according to the value in the pop up menu.
case ...: set(hslider,'Min',5,'Max',12);
end
end
You can find how to set the values of the slider and other uicontrols in the documentation of Matlab. Just write uicontrol.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!