z=f(x,y) and w=f(x,y). I am trying to reverse the table to get x=f(z,w) and y=f(z,w).
4 views (last 30 days)
Show older comments
Sobhi Zeidan on 7 Mar 2023
I have a 2 lookup tables with same X and Y but the outputs are Z and W. Basicaly I have a z=f(x,y) and w=f(x,y). I am trying to reverse the table to get x=f(z,w) and y=f(z,w). what is the best way of doing that in Matlab. the table data is in this format:
In general, this is often impossible. That is so for good reasons too.
The problem is, IF you have any instances where the responses would not be a single valued function, then it would fail. For example:
syms x y
z = x.^2 + y.^2;
For any value of z and x, you can find two values of y. So the coutours of z here are circles in the (x,y) plane, and so there is no unique way to invert this function in a table.
But we can look at your problem. Does that data suffer from any issues that would cause failure? Some contour plots will help us there.
A=[17.9 18.0 18.1 18.2]';
B=[0.4 0.5 0.6 0.7];
C=[67 89 95 108
74 92 110 123
80 97 115 127
84 106 119 135];
D=[40 65 80 95
50 72 85 103
60 93 97 110
70 100 103 127];
So there are no overtly problematic contours that I see. There are no circular contours. There are no places where a contour is u-shaped. So does that mean a solution MUST exist? There are still problems.
We can use these contour plots to understand what is happening. I've picked out two contour levels that will be problematic for you.
legend('D == 80','C == 100')
Do you see what I did? The contour plot of D==80 and that of C==100, cross at TWO distinct points in the (A,B) plane. And that means there is no inverse for your problem. You CANNOT use a scattered interpolant here. There is no unique solution.
Star Strider on 7 Mar 2023
Apparently, X, Y, Z and W are all equal-sized matrices. Assuming that there is essentially a one-to-one correspondence between the matrices, it could be possible to do this with the scatteredInterpolant function. Everything essentially depends on the functions that create Z and W.
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!