Look up a value in a Table based a specified Row and Column
133 次查看(过去 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!