How to find two values in a 3D table?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello ML experts,
I have the two tables below and I need to find the X and Y values from the first table in the second table to return the Z value. For example, for the variable a, searching for Y=31 and X=3.7 in the second table should return the Z value as a result of an interpolation of X between 3 and 4 and Y between 30 and 40. Please any idea how to get it?
First table Second table
Y X 1 2 3 4 5 6
a 31 3.7 10 16 17 17 17 19 17
b 22 3.4 20 23 22 22 22 24 24
c 55 2.7 30 31 29 28 27 29 31
d 23 4.5 40 38 36 35 34 34 35
e 11 2.5 50 48 47 46 44 44 42
60 59 58 57 56 54 48
Thanks!
0 件のコメント
採用された回答
David Hill
2022 年 12 月 12 日
B=[ 16 17 17 17 19 17
23 22 22 22 24 24
31 29 28 27 29 31
38 36 35 34 34 35
48 47 46 44 44 42
59 58 57 56 54 48];
A=[31.0000 3.7000
22.0000 3.4000
55.0000 2.7000
23.0000 4.5000
11.0000 2.5000];
[x,y]=meshgrid(1:6,10:10:60);
for k=1:size(A,1)
z(k)=interp2(x,y,B,A(k,2),A(k,1),'linear');
end
z
その他の回答 (2 件)
Bora Eryilmaz
2022 年 12 月 12 日
編集済み: Bora Eryilmaz
2022 年 12 月 12 日
X = [1 2 3 4 5 6]';
Y = [10 20 30 40 50 60]';
V = [16 17 17 17 19 17; ...
23 22 22 22 24 24; ...
31 29 28 27 29 31; ...
38 36 35 34 34 35; ...
48 47 46 44 44 42; ...
59 58 57 56 54 48];
x = 3.5;
y = 31;
interpn(X,Y,V,x,y)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!