pop up menu and slider....
조회 수: 4 (최근 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!