# Look up a value in a Table based a specified Row and Column

조회 수: 109 (최근 30일)
Veronica Vigil 2023년 8월 20일
답변: Seth Furman 2023년 9월 14일
Hello! Okay I've asked this in various different questions, but am still having trouble. So I am going to try to break this down. I need to be able to look up a value in a large Excel Table (one sheet of data) based on the row and column. The row to look up is inclination, and is numbers based from 10 to 170 (i.e. 10, 11, 12,...,169, 170) and the Column for Altitude from 300 to 1200 (i.e. 300, 301, 302,..., 1198, 1199, 1200). Here is what I have, but it's not working. NOTE: This will eventually go into App Designer. I have the rest of the App Designer working, I only need the code for reading the value from the Excel table and displaying it based on the user input. Here is what I have, and it just keeps giving me the Value of "1" - if you open up the table, all of these values are x.xxe-7 (ish). Table is attached. What I want it to do is when I change 'xvalue' and 'yvalue' it will look up the number that's corresponding to those two numbers.
inclination = Table{1,2:end};
altitude = Table{2:end,1};
xvalue = 10;
yvalue = 300;
xvar = find(inclination==xvalue);
yvar = find(altitude==yvalue);
Int = find(xvar,yvar);
NOTE: I have tried readmatrix, but I get this error: Brace indexing is not supported for variables of this type.

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

### 채택된 답변

Voss 2023년 8월 20일
inclination = Table{1,2:end};
altitude = Table{2:end,1};
xvalue = 10;
yvalue = 300;
xvar = find(inclination==xvalue);
yvar = find(altitude==yvalue);
Int = Table{yvar+1,xvar+1}
Int = 3.4780e-08
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Veronica Vigil 2023년 8월 20일
@Voss you. are. THE BEST. Now here's to hoping I can get this included into my app designer code!

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

### 추가 답변 (1개)

Seth Furman 2023년 9월 14일
It's worth mentioning that the error "Brace indexing is not supported for variables of this type." occurs because double arrays must be indexed with parentheses-() instead of curly braces-{}.
data = 902×163
NaN 0 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000 23.0000 24.0000 25.0000 26.0000 27.0000 28.0000 29.0000 30.0000 31.0000 32.0000 33.0000 34.0000 35.0000 36.0000 37.0000 300.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 301.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 302.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 303.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 304.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 305.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 306.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 307.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 308.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
inclination = data(1,2:end);
altitude = data(2:end,1);
xvalue = 10;
yvalue = 300;
Int = data(inclination == xvalue, altitude == yvalue)
Int = 300

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

### 카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by