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).
9 次查看(过去 30 天)
显示 更早的评论
Hello,
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:
5 个评论
回答(2 个)
John D'Errico
2023-3-9
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;
fsurf(z)
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];
contour(A,B,C)
contour(A,B,D)
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.
contour(A,B,D,[80 80],'r')
hold on
contour(A,B,C,[100 100],'b')
hold off
legend('D == 80','C == 100')
grid on
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
2023-3-7
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.
6 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!