Multi-variable interpolation, grids and 2D guessing
4 views (last 30 days)
I have a regular grid of (x,y) points. Each point in turn has an associated value of a range and frequency variable, that means that each (xi,yi) point has an associated (ri, fi) value. Another way of seeing it is that for each (x,y) point I have a r grid and a f grid ( r = function(x,y) and f = function(x,y)). Hence the r and f are not 'regular' let's say, as they are constructed with a specific function.
Now my question is: I want to find, given a set of (r,f) points, which is the corresponding (x,y) point that would yield those (r,f) values. Very likely the corresponding (x,y) will not exist in the original grid so they have to be 'guessed' somehow (probably with a given tolerance?). So as a result, for the set of (r,f) points I would like to find the set of guessed (x,y) points.
I don't know whether I made myself clear...hopefully yes!!
Thanks everyone in advance!!
John D'Errico on 8 Apr 2020
Edited: John D'Errico on 8 Apr 2020
Yes. you make yourself clear.
This is a nonlinear optimization problem. Sometimes it might be called a calibration problem.
Actually, it is essentially a rootfinding problem in 2-dimensions, as long as the transformation from the (x,y) domain to the (r,f) domain is nonlinear. If that mapping was linear, then the solution is simple and linear itself too. That is, if the transformation was a linear one, then the solution is no more difficult than a solution of a linear system of equations. If any nonlineararity exists at all, then you might use a tool like fsolve. However fsolve can sometimes fail to produce a valid result, even when one exists.
Be careful here. If you are using a tool like fsolve to solve the problem, but you treat the mapping forward from (x,y) into the (r,f) domain using interp2 with linear interpolation, then fsolve will have a problem, since interp2 need not produce a differentiable function.
There are several problems in either case. In some circumstances there will be no solution at all, even if the problem can be solved using a linear mapping. Or, if the mapping is sufficiently nonlinear, then there may be several solutions for any (r,f), all equally valid.
What is the best way to solve it? There is one fairly foolproof solution that is not too difficult to implement. However, if the transformation was actually a linear mapping, then there is an even easier solution. Some people might know the phrase "affine mapping" or "affine transformation". Either correspond to what I described as linear above.
So which is it, before I spend an hour to write something up sufficiently well that you will understand what I am doing? (And then respond to your questions, which people always have anyway.) Is the mapping linear or nonlinear?
EDIT: How to solve the NONLINEAR inverse mapping.
This really is just a short explanation of how to solve a nonlinear rootfinding problem in 2-dimensions. First, I'll return to a more clear explanation of the problem.
Thus, imagine you start out with a sheet of paper, laid out in a grid, thus (x,y). Now, imagine you taking the sheet, and stretch it nonlinearly, deforming it like a piece of rubber. We can visualize it as...
rfun = @(x,y) x + (y+1).^2/5;
ffun = @(x,y) (x+2).*sin((2*x+y)/10 - 0.5);
[xg,yg] = meshgrid(-1:.1:1);
rg = rfun(xg,yg);
fg = ffun(xg,yg);
title 'Undeformed lattice'
Next, look at the deformed sheet. Be careful. The first example I cooked up had that sheet twisted and deformed in VERY strange ways. It was just too nonlinear of a transformation. The example I show below is a VERY MILD transformation, but even here you should see it is becoming problematic in one corner.
title 'Rubber sheet deformation'
As you can see, in the upper right corner, the rubber sheet has actually become just slightly twisted on itself.
How should we interpret these plots? Here, I want you to visualize a set of arrows connecting the two figures. Every point in the (x,y) lattice has a corresponding point in the (r,f) lattice. Your goal of course, is to solve the inverse problem. That is, for any point in the deformed sheet, you want to know what the origin of that point would have been, in the original lattice.
I hope we now understand the problem. Now, can we solve it? How would that be done? ... (Writing more)