Help me on this Code

*
function listbox1 _Callback(hObject, eventdata, handles)
index_selected = get(hObject,'Value');
list = get(hObject,'String');
item_selected = list{index_selected}; % Convert from cell array % to strin
disp(item_selected);
function listbox2 _Callback(hObject, eventdata, handles)
index_selected = get(hObject,'Value');
list = get(hObject,'String');
item_selected2 = list{index_selected};
disp(item_selected2);
function OK_PUSHBUTTON _Callback(hObject, eventdata, handles)
function itemFromColumnC = GetColumnC(handles, textdata);
itemFromColumnC = []; % Initialize to null
% Get the item number that they selected.
selected1 = get(handles.item_selected1, 'value');
selected2 = get(handles.item_selected2, 'value');
% Get the contents items1 = get(handles.item_selected2, 'String');
items2 = get(handles.item_selected2, 'String'); % Get the selected item
selectedItem1 = items1{selected1};
selectedItem2 = items2{selected2};
% Now compare
if selected1 == selected2
itemFromColumnC = textdata{selected1, 3};
end message = sprintf('%s',itemFromColumnC);
uiwait(msgbox(message));
For Example:
Listbox1 input=" PAss"
Listbox2 input=" Fail"
Grade Output =" D Grade"
(See the 7th row in xls sheet)

댓글 수: 4

Jan
Jan 2013년 9월 24일
If you want us to help, it would be helpful, if you mention the problem. The more details the better.
Image Analyst
Image Analyst 2013년 9월 24일
Aren't you already working on this in this discussion?
Mary
Mary 2013년 9월 24일
Yes... I tried the same with double values and prompt msgs. Now iam trying the same with string values and listbox
Mary
Mary 2013년 9월 24일
@Jan Simon :
I Have 2 listboxes and one pushbutton in my gui.
If I select inputs from listbox and OK Button is clicked then it has to compare with the excel sheet values. Once it got the match of 2 inputs then it has to display the corresponding 3rd column value.
If I select Pass and Fail from listbox1 and listbox2 respectively...then it has to display the corresponding 3rd column value i.e, D Grade

답변 (1개)

Image Analyst
Image Analyst 2013년 9월 24일

0 개 추천

I think you want to use strcmpi() instead of ==
if strcmpi(selectedItem1, selectedItem2)
% They match
else
% they don't match
end

댓글 수: 1

Mary
Mary 2013년 9월 24일
No...it is not comparing the string values

이 질문은 마감되었습니다.

태그

아직 태그를 입력하지 않았습니다.

질문:

2013년 9월 24일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by