compare columns & Display output using excel sheet

i have 3 columns in abc.xlsx and the data is
X Y Z
1 1 10
1 2 20
1 3 30
1 4 40
1 5 50
2 1 60
2 2 70
2 3 80
2 4 90
2 5 100
3 1 110
3 2 120
3 3 130
3 4 140
now user will enter any two values that i want to match with X and Y Column once the match is found then i want to display corresponding c column cell value
for eg: My input is 2 and 3 then i want to display the value 80

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 5일
편집: Azzi Abdelmalek 2013년 8월 5일

1 개 추천

A=[ 1 1 10
1 2 20
1 3 30
1 4 40
1 5 50
2 1 60
2 2 70
2 3 80
2 4 90
2 5 100
3 1 110
3 2 120
3 3 130
3 4 140]
x=2,
y=3,
out=A(ismember(A(:,1:2),[x y],'rows'),3)

댓글 수: 7

Dimple commented
Thank u for the solution.
1.how to read values from any xls sheet or text files having 100's of rows 2.output is based on any user entered value.
Dimple, To add a comment, just click on comment on this answer
Dimple
Dimple 2013년 8월 5일
ok
Look at xlsread function to read excell file and textscan or fgetl to read text files
Dimple
Dimple 2013년 8월 5일
Actually iam new to the matlab.So started learning now.
My objective is to create gui with two input dialog boxes.
User will enter the values. After that i want to compare that user entered values with excel sheet cell values.if the match is found then it has to display the 3rd column value as the answer
Dimple
Dimple 2013년 8월 6일
i want to create a gui with two input dialog boxes.
User will enter the values.
After that i want to compare the user entered values with excel sheet two column's cell values.if the match is found then it has to display the 3rd column value as the answer
Dimple
Dimple 2013년 8월 20일
Suppose if x and y values are from prompt.then how to read values for x and y

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

추가 답변 (1개)

Dimple
Dimple 2013년 8월 20일

0 개 추천

prompt{1}='Enter 1st grade :'; prompt{2}='Enter 2nd grade :'; name='result'; answer=inputdlg(prompt,name); a=xlsread('inputdata.xlsx');
excel file values are
0.1 0.1 0.1 0.1 0.2 0.1 0.1 0.3 0.1 0.1 0.4 0.2 0.1 0.5 0.2 0.1 0.6 0.2 0.1 0.7 0.3 0.1 0.8 0.3 0.2 0.1 0.1 0.2 0.2 0.2 0.2 0.3 0.2 0.2 0.4 0.2 0.2 0.5 0.3 0.2 0.6 0.3 0.2 0.7 0.3 0.2 0.8 0.4 0.3 0.1 0.1 0.3 0.2 0.2 0.3 0.3 0.2
1st grade values are in 1st column 2nd grade values are in 2nd column
if user enter values for 1st and 2nd grade, then it has to display the output. output is the corresponding 3rd column value.
for eg: Enter 1st grade : 0.2
Enter 2nd grade :0.8
output is 0.4

댓글 수: 1

Dimple, is this an answer or a question? If you want to ask a new question, post a new one in Ask a question

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

카테고리

태그

Community Treasure Hunt

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

Start Hunting!

Translated by