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

22 ビュー (過去 30 日間)
Zarif Rahman
Zarif Rahman 2021 年 4 月 8 日
編集済み: Adam Danz 2021 年 4 月 8 日
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.

採用された回答

Adam Danz
Adam Danz 2021 年 4 月 8 日
編集済み: Adam Danz 2021 年 4 月 8 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by