Look up a value in a Table based a specified Row and Column
130 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Veronica Vigil
le 20 Août 2023
Réponse apportée : Seth Furman
le 14 Sep 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 commentaires
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}
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")
inclination = data(1,2:end);
altitude = data(2:end,1);
xvalue = 10;
yvalue = 300;
Int = data(inclination == xvalue, altitude == yvalue)
0 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!