Convert 3D Lookup Table
6 次查看(过去 30 天)
显示 更早的评论
Hi,
I got a lookup table that looks like the following:
-Inf 40 50 60
0.70 22.70 9.24 6.78
0.65 20.45 8.85 6.42
0.60 19.23 8.48 6.69
0.55 18.04 8.03 6.28
0.50 16.89 7.63 6.49
Normally the inputs for the lookup table are:
X = 40 50 60
Y = 0.70 0.65 0.60 0.55 0.5
And the other values is the interpolated output Z.
Now I want to convert the lookup table / this matrix so that
Y=Z .
This means, that I want the Z and the X Values as input and X as output.
How can I convert the matrix to get this ?
Thanks :)
1 个评论
Walter Roberson
2015-7-29
Your notation
Y=Z .
confuses me. You also said you want the Z and X as input and the X as output. Perhaps you want Z and X as input and Y as output? Y = Table(Z, X) ?
回答(1 个)
Walter Roberson
2015-7-29
编辑:Walter Roberson
2015-8-7
function Y = lookupY(X, Z)
XYZ = [-Inf 40 50 60
0.70 22.70 9.24 6.78
0.65 20.45 8.85 6.42
0.60 19.23 8.48 6.69
0.55 18.04 8.03 6.28
0.50 16.89 7.63 6.49];
[numrow, numcol] = size(XYZ);
xcol = interp1(XYZ(1,2:end), 2:numcol, X, 'nearest', 'extrap');
yrow = interp1(XYZ(2:end, xcol), 2:numrow, Z, 'nearest', 'extrap');
Y = XYZ(yrow, 1);
[note: some errors have been corrected]
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!