Compare two column values and display the third column value from the excel based on list box input.

조회 수: 5(최근 30일)
i have a excel sheet which is having 3 columns each column is having the student information.
1st and 2nd columns are having the semester-I and semester-II status respectively like "pass", "Fail", "Distinction", "first", "second", "third class"..etc
In my GUI, i have two list box which is for sem-I and Sem-II marks. if i select any input from the both list box then it has to compare with the excel sheet row values.
once both the list box inputs are found in the excel sheet, then it has to display the 3rd column value as the output
for example
if i select "distinction" from 1st list box and "Fail" from 2nd listbox then it has to show the corresponding value from the 3rd column...
  댓글 수: 1
Mary 2013년 9월 23일
편집: Mary 2013년 9월 23일
Are u not getting my questions?.......oops iam not getting any reply from u all

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


Vishal Rane
Vishal Rane 2013년 9월 23일
If you need to read data from excel and display it in the listbox:
- use xlsread to read data from the specific cells
- assign the data to the listboxes using set()
  댓글 수: 3
Mary 2013년 9월 24일
편집: Mary 2013년 9월 24일
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 string
function listbox2 _Callback(hObject, eventdata, handles)
index_selected = get(hObject,'Value');
list = get(hObject,'String');
item_selected2 = list{index_selected};
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);
If I select pass from listbox1 and fail from listbox2 then it has to display the D Grade as an output (See the 7th row in excel sheet).

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


Community Treasure Hunt

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

Start Hunting!

Translated by