필터 지우기
필터 지우기

Listbox MATLAB GUI issue : How to pass two list box values to the 3rd listbox

조회 수: 1 (최근 30일)
Hi everyone,
I am trying to pass 2 list box values to the third list box but it seems I am not getting what I am looking for.
Can anyone guide me in this matter please.

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 16일
In the place you fetch the strings and values for the listboxes, also fetch the Enable property, and if it is not on then use the value (index) for the first listbox to index the second listbox as well.
  댓글 수: 3
Walter Roberson
Walter Roberson 2015년 9월 16일
function pushbutton1_Callback(hObject, eventdata, handles)
str1 = cellstr(get(handles.listbox1, 'string'));
val1 = get(handles.listbox1, 'value');
str2 = cellstr(get(handles.listbox2, 'string'));
val2 = get(handles.listbox2, 'value');
if isempty(val1)
selection1 = '';
else
selection1 = str1{val1};
end
enable_state2 = get(handles.listbox2, 'Enable');
if ~strcmp(enable_state2, 'on')
val2 = val1;
end
if isempty(val2)
selection2 = '';
else
selection2 = str2{val2};
end
combined_selection = {selection1; selection2};
set(handles.listbox3, 'string', combined_selection);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by