Look up a value in a Table based a specified Row and Column
123 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Voss
2023 年 8 月 20 日
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}
その他の回答 (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 = readmatrix("FluxDataInterpolated.xlsx")
inclination = data(1,2:end);
altitude = data(2:end,1);
xvalue = 10;
yvalue = 300;
Int = data(inclination == xvalue, altitude == yvalue)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!