Thread Subject: inverse lookup table

Subject: inverse lookup table

From: S?ren Sieberling

Date: 23 Nov, 2009 10:48:03

Message: 1 of 9

Hello,

I have two lookup tables, such that

    Ca = Ca(a,b) and Cb = Cb(a,b).

I however want to invert them, such that I get,

    a = a(Ca,Cb) and b = b(Ca,Cb).

This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.

Soeren

Subject: inverse lookup table

From: ImageAnalyst

Date: 23 Nov, 2009 11:21:21

Message: 2 of 9

On Nov 23, 5:48 am, "S?ren Sieberling" <seure...@hotmail.com> wrote:
> Hello,
>
> I have two lookup tables, such that
>
>     Ca = Ca(a,b) and Cb = Cb(a,b).
>
> I however want to invert them, such that I get,
>
>     a = a(Ca,Cb) and b = b(Ca,Cb).
>
> This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.
>
> Soeren

--------------------------
You can use the find() function. It will tell you which indices
particular matrix values occur at. You'll have to combine two find
results together (probably with the intersect() or ismember()
function) to check for both Ca and Ca.

Subject: inverse lookup table

From: John D'Errico

Date: 23 Nov, 2009 12:18:03

Message: 3 of 9

"S?ren Sieberling" <seuren83@hotmail.com> wrote in message <hedp93$ehd$1@fred.mathworks.com>...
> Hello,
>
> I have two lookup tables, such that
>
> Ca = Ca(a,b) and Cb = Cb(a,b).
>
> I however want to invert them, such that I get,
>
> a = a(Ca,Cb) and b = b(Ca,Cb).
>
> This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.
>
> Soeren

So you want to solve a system of two equations, in
two unknowns. This would normally be handled by
fsolve, however, you don't actually have equations.
All that you have are a set of sampled points.

Define an interpolation method, then you might use
a solver. Of course, fsolve might try to wander outside
of the defined domain. It might also get trapped, if
your interpolant is not smooth enough.

Other methods are available. For example, if you are
willing to accept a linear approximation, then look
for intersections of the polygonal curves generated by
two contour plots.

HTH,
John

Subject: inverse lookup table

From: Jan Simon

Date: 23 Nov, 2009 17:47:04

Message: 4 of 9

Dear Soeren!

> I have two lookup tables, such that
>
> Ca = Ca(a,b) and Cb = Cb(a,b).
>
> I however want to invert them, such that I get,
>
> a = a(Ca,Cb) and b = b(Ca,Cb).
>
> This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.

Do I understand correctly: Ca and Cb are matrices, while a and b are vectors in the first equation. In the 2nd equation Ca and Cb are vectors and a and b are the matrices?
I assume that your a = a(Ca, Cb) is a matrix also and it can be defined uniquely. So can you give an example with [3x3] arrays?

I'm thinking on something like:
  data = 1:9; data = data(randperm(9)); % Test data
  Table = reshape(data, 3, 3);
  InvTable(Table) = 1:9;

Kind regards, Jan

Subject: inverse lookup table

From: S?ren Sieberling

Date: 24 Nov, 2009 09:41:03

Message: 5 of 9

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <heehqo$lm8$1@fred.mathworks.com>...
> Dear Soeren!
>
> > I have two lookup tables, such that
> >
> > Ca = Ca(a,b) and Cb = Cb(a,b).
> >
> > I however want to invert them, such that I get,
> >
> > a = a(Ca,Cb) and b = b(Ca,Cb).
> >
> > This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.
>
> Do I understand correctly: Ca and Cb are matrices, while a and b are vectors in the first equation. In the 2nd equation Ca and Cb are vectors and a and b are the matrices?
> I assume that your a = a(Ca, Cb) is a matrix also and it can be defined uniquely. So can you give an example with [3x3] arrays?
>
> I'm thinking on something like:
> data = 1:9; data = data(randperm(9)); % Test data
> Table = reshape(data, 3, 3);
> InvTable(Table) = 1:9;
>
> Kind regards, Jan

Hello,

Thanks for your replies. Indeed what you are assuming is correct. I will give an example

a = [ 1 2 3]
b = [-1 0 1]

Ca = [0.1 0 0.1; 1.1 1.0 1.1; 2.1 2.0 2.1];
Cb = [-1 0 1; -1.1 0 1.1; -1.2 0 1.2];

Where b can be seen as column index and a as row index. I want to get something like:

Ca = [0 1 2]
Cb = [-2 0 2]

a = [3x3]
b = [3x3]

with Cb as column index and Ca as row index. I hope this clears up my problem. Every combination of Ca and Cb should be able to specify a value for a and b uniquely.

Kind regards,
Soeren

Subject: inverse lookup table

From: John D'Errico

Date: 24 Nov, 2009 10:47:04

Message: 6 of 9

"S?ren Sieberling" <seuren83@hotmail.com> wrote in message <heg9nf$gma$1@fred.mathworks.com>...
> "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <heehqo$lm8$1@fred.mathworks.com>...
> > Dear Soeren!
> >
> > > I have two lookup tables, such that
> > >
> > > Ca = Ca(a,b) and Cb = Cb(a,b).
> > >
> > > I however want to invert them, such that I get,
> > >
> > > a = a(Ca,Cb) and b = b(Ca,Cb).
> > >
> > > This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.
> >
> > Do I understand correctly: Ca and Cb are matrices, while a and b are vectors in the first equation. In the 2nd equation Ca and Cb are vectors and a and b are the matrices?
> > I assume that your a = a(Ca, Cb) is a matrix also and it can be defined uniquely. So can you give an example with [3x3] arrays?
> >
> > I'm thinking on something like:
> > data = 1:9; data = data(randperm(9)); % Test data
> > Table = reshape(data, 3, 3);
> > InvTable(Table) = 1:9;
> >
> > Kind regards, Jan
>
> Hello,
>
> Thanks for your replies. Indeed what you are assuming is correct. I will give an example
>
> a = [ 1 2 3]
> b = [-1 0 1]
>
> Ca = [0.1 0 0.1; 1.1 1.0 1.1; 2.1 2.0 2.1];
> Cb = [-1 0 1; -1.1 0 1.1; -1.2 0 1.2];
>
> Where b can be seen as column index and a as row index. I want to get something like:
>
> Ca = [0 1 2]
> Cb = [-2 0 2]
>
> a = [3x3]
> b = [3x3]
>
> with Cb as column index and Ca as row index. I hope this clears up my problem. Every combination of Ca and Cb should be able to specify a value for a and b uniquely.
>
> Kind regards,
> Soeren

No! You cannot do that, simply invert this general,
arbitrary nonlinear relationship into a nice simple
relationship that you can easily plot! There is no
reason to assume that a well defined (unique)
inverse even exists at every point in the plot you
describe. Under certain conditions, you might be
able to achieve this goal for a limited (probably
non-rectangular) domain of the (a,b) plane.

The best that you can do in general is for a given
pair of levels for Ca and Cb, you can compute
corresponding values of a and b that yield the
desired Ca and Cb by interpolation. There may be
multiple solutions to this problem though.

For this, do as I suggested. Use contourc twice. Get
contour polygons for Ca and then also for Cb at
your desired values of those parameters. Then use a
tool that can find all intersections of these plane
curves in (a,b). Doug Schwarz has written a nice
one, found on the file exchange.

John

Subject: inverse lookup table

From: S?ren Sieberling

Date: 24 Nov, 2009 11:16:19

Message: 7 of 9

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <hegdj8$a4o$1@fred.mathworks.com>...
> "S?ren Sieberling" <seuren83@hotmail.com> wrote in message <heg9nf$gma$1@fred.mathworks.com>...
> > "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <heehqo$lm8$1@fred.mathworks.com>...
> > > Dear Soeren!
> > >
> > > > I have two lookup tables, such that
> > > >
> > > > Ca = Ca(a,b) and Cb = Cb(a,b).
> > > >
> > > > I however want to invert them, such that I get,
> > > >
> > > > a = a(Ca,Cb) and b = b(Ca,Cb).
> > > >
> > > > This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.
> > >
> > > Do I understand correctly: Ca and Cb are matrices, while a and b are vectors in the first equation. In the 2nd equation Ca and Cb are vectors and a and b are the matrices?
> > > I assume that your a = a(Ca, Cb) is a matrix also and it can be defined uniquely. So can you give an example with [3x3] arrays?
> > >
> > > I'm thinking on something like:
> > > data = 1:9; data = data(randperm(9)); % Test data
> > > Table = reshape(data, 3, 3);
> > > InvTable(Table) = 1:9;
> > >
> > > Kind regards, Jan
> >
> > Hello,
> >
> > Thanks for your replies. Indeed what you are assuming is correct. I will give an example
> >
> > a = [ 1 2 3]
> > b = [-1 0 1]
> >
> > Ca = [0.1 0 0.1; 1.1 1.0 1.1; 2.1 2.0 2.1];
> > Cb = [-1 0 1; -1.1 0 1.1; -1.2 0 1.2];
> >
> > Where b can be seen as column index and a as row index. I want to get something like:
> >
> > Ca = [0 1 2]
> > Cb = [-2 0 2]
> >
> > a = [3x3]
> > b = [3x3]
> >
> > with Cb as column index and Ca as row index. I hope this clears up my problem. Every combination of Ca and Cb should be able to specify a value for a and b uniquely.
> >
> > Kind regards,
> > Soeren
>
> No! You cannot do that, simply invert this general,
> arbitrary nonlinear relationship into a nice simple
> relationship that you can easily plot! There is no
> reason to assume that a well defined (unique)
> inverse even exists at every point in the plot you
> describe. Under certain conditions, you might be
> able to achieve this goal for a limited (probably
> non-rectangular) domain of the (a,b) plane.
>
> The best that you can do in general is for a given
> pair of levels for Ca and Cb, you can compute
> corresponding values of a and b that yield the
> desired Ca and Cb by interpolation. There may be
> multiple solutions to this problem though.
>
> For this, do as I suggested. Use contourc twice. Get
> contour polygons for Ca and then also for Cb at
> your desired values of those parameters. Then use a
> tool that can find all intersections of these plane
> curves in (a,b). Doug Schwarz has written a nice
> one, found on the file exchange.
>
> John

Thanks big time John. This is exactly what I was looking for. What I should have also told you is that from physical considerations I know for a fact that the contour lines will only run from "left" to "right" in the Ca matrix and from "top" to "bottom" in the Cb matrix. Hence for each a and b the value of Ca and Cb is defined, the opposite is also true.

The tool written by Schwarz is exactly what I needed.

Kind regards,
Soeren

Subject: inverse lookup table

From: Bruno Luong

Date: 24 Nov, 2009 11:52:04

Message: 8 of 9

You could also approximate the inverse by interpolate the scattered data using GRIDDATA (one for each components) for example.

If exact inversion is required, build the forward interpolation (original lookup table) then call FSOLVE to invert your map (from R^2 to R^2).

Bruno

Subject: inverse lookup table

From: Yakup

Date: 30 Nov, 2011 15:22:08

Message: 9 of 9

"Sören Sieberling" wrote in message <hedp93$ehd$1@fred.mathworks.com>...
> Hello,
>
> I have two lookup tables, such that
>
> Ca = Ca(a,b) and Cb = Cb(a,b).
>
> I however want to invert them, such that I get,
>
> a = a(Ca,Cb) and b = b(Ca,Cb).
>
> This should be possible, but I can't manage to find a way. Does somebody have an idea? Thanks in advance.
>
> Soeren



Use iterative way via using your look up tables in simulink.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
interp Sören Sieberling 23 Nov, 2009 05:49:05
interp1 Sören Sieberling 23 Nov, 2009 05:49:05
interp2 Sören Sieberling 23 Nov, 2009 05:49:05
lookup table Sören Sieberling 23 Nov, 2009 05:49:05
rssFeed for this Thread

Contact us at files@mathworks.com