How to set MATLAB GUI drop down to be empty be default

7 Ansichten (letzte 30 Tage)
Zarif Rahman
Zarif Rahman am 8 Apr. 2021
Bearbeitet: Adam Danz am 8 Apr. 2021
dd = uidropdown(fig,...
'Position',[30 120 200 22],...
'Items',{'bayesian_optimization','opto_configure_gamma_gp_uncertainty_sampling',...
'grid_search1','grid_search3','electrical_stimulation','cross_entropy','pid_controller',...
'bayesian_optimization','bayesian_optimization2','theta_optimization', 'gamma_maximization', ...
'random_nested_pulse_train', 'opto_configure_gamma_gp_uncertainty_sampling'},...
'Editable','on');
This is my drop down code. By default it goes to the first value on the list which is Bayesian Optimization. Can we have it where it defaults to nothing? And is there way to add functionality to that aswell? Like making every button greyed out until that drop down selected.

Akzeptierte Antwort

Adam Danz
Adam Danz am 8 Apr. 2021
Bearbeitet: Adam Danz am 8 Apr. 2021
By default, uidropdown uses the first item as the default item but you can also specify the Value property to display another value.
Here I've specified an empty character array to appear when the uidropdown is rendered.
dd = uidropdown(fig,...
'Position',[30 120 200 22],...
'Items',{'bayesian_optimization','opto_configure_gamma_gp_uncertainty_sampling',...
'grid_search1','grid_search3','electrical_stimulation','cross_entropy','pid_controller',...
'bayesian_optimization','bayesian_optimization2','theta_optimization', 'gamma_maximization', ...
'random_nested_pulse_train', 'opto_configure_gamma_gp_uncertainty_sampling'},...
'Editable','on','Value', ''); % <------ specify value
Use the ValueChangedFcn to control the behavior of app components when there is a selection from the dropdown menu. See examples in the documentation.

Weitere Antworten (0)

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by