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

125 vues (au cours des 30 derniers jours)
Veronica Vigil le 20 Août 2023
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.
Table = readtable('FluxDataInterpolated.xlsx');
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.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Voss le 20 Août 2023
Table = readtable('FluxDataInterpolated.xlsx');
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 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Veronica Vigil le 20 Août 2023
@Voss you. are. THE BEST. Now here's to hoping I can get this included into my app designer code!

Connectez-vous pour commenter.

### Plus de réponses (1)

Seth Furman le 14 Sep 2023
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 = readmatrix("FluxDataInterpolated.xlsx")
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
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by