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)
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:
Torsten on 7 Mar 2023
Edited: Torsten on 7 Mar 2023
FluxQ=Iq x Lq(inductance) FlusD= FluxPM + Id x Lq
If you have equations z = f1(x,y) and w = f2(x,y), why don't you solve for x and y given z and w ?
Two equations in two unknowns.

Sign in to comment.

Answers (2)

John D'Errico
John D'Errico on 9 Mar 2023
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.
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.
Torsten on 9 Mar 2023
Edited: Torsten on 9 Mar 2023
the equation is a linear equation and should have a one to one correspondence .
As noted above, if you have equations, you can solve for the unknowns.
syms x y z w
eqn1 = z == 3*x+5*y+7;
eqn2 = w == -4*x+8*y-12;
solve([eqn1 eqn2],[x y])
ans = struct with fields:
x: (2*z)/11 - (5*w)/44 - 29/11 y: (3*w)/44 + z/11 + 2/11

Sign in to comment.

Star Strider
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.

Sign in to comment.


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!