フィルターのクリア

How do I replace the sting value in one popup based on the value selected in another popup?

1 回表示 (過去 30 日間)
popupMenu = uicontrol(topPanel,'Style','popupmenu',...
'String',solString,...
'Units','normalized',...
'Value',1,'Position',[.1 .25 .2 .5],...
'Callback',@popupmenuCallBack);
hourpopupMenu = uicontrol(topPanel,'Style','popupmenu',...
'String',hourString,...
'Units','normalized',...
'Value',1,'Position',[.5 .25 .2 .5],...
'Callback',@hourpopupmenuCallBack);
function hourpopupmenuCallBack(hObject, eventdata, handles)
global sol_index_selected
global hour_index_selected
global solution_index
global allData
hour_index_selected = get(hObject,'Value');
% to generate new string
newSolString = [];
for n=1:size(allData.all_data(hour_index_selected).solutions,1)
newSolString = [newSolString string("Solution "+n)];
end
% NEED TO REPLACE STRING OF "popupmenu" WITH "newSolString"
end
% callback function for dropdown/popup menu in the top panel
function popupmenuCallBack(hObject, eventdata, handles)
global sol_index_selected
sol_index_selected = get(hObject,'Value');
end

採用された回答

Walter Roberson
Walter Roberson 2017 年 6 月 12 日
Change
popupMenu = uicontrol(topPanel,'Style','popupmenu',...
'String',solString,...
'Units','normalized',...
'Value',1,'Position',[.1 .25 .2 .5],...
'Callback',@popupmenuCallBack);
to
popupMenu = uicontrol(topPanel,'Style','popupmenu',...
'String',solString,...
'Units','normalized',...
'Value',1,'Position',[.1 .25 .2 .5],...
'Callback',@popupmenuCallBack, ...
'tag', 'Pup');
Replace
newSolString = [];
for n=1:size(allData.all_data(hour_index_selected).solutions,1)
newSolString = [newSolString string("Solution "+n)];
end
with
newSolString = 'Solution " + (1:size(allData.all_data(hour_index_selected).solutions,1));
popupmenu = findobj(ancestor(hObject, 'figure'), 'tag', 'Pup');
popupmenu.String = newSolString;
  2 件のコメント
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 12 日
@Walter
Thank you for the answer. Just inquisitive, can we pass some parameters along with the above callback function? And how do we access the same..
If yes can you please state an example for the same.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by