pop up menu and slider....
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Hugo
el 7 de Jun. de 2013
Editada: Hugo
el 7 de Jun. de 2013
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 comentarios
Hugo
el 7 de Jun. de 2013
Editada: Hugo
el 7 de Jun. de 2013
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!