Convert 3D Lookup Table
6 views (last 30 days)
Show older comments
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 Comment
Walter Roberson
on 29 Jul 2015
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) ?
Answers (1)
Walter Roberson
on 29 Jul 2015
Edited: Walter Roberson
on 7 Aug 2015
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 Comments
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!