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

조회 수: 5 (최근 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 CenterFile Exchange에서 App Building에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by