Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simulink n-dimensional scatter data interpolation

750 views
Skip to first unread message

Alvaro Canivell

unread,
Feb 10, 2010, 11:33:05 AM2/10/10
to
Hello everybody

I have a 4-dimensional set of experimental data:

v = f(x,y,z)

Where:
- x, y, z, v are 1x20 vectors.
- f is UNKNOWN in fact it is what I need to estimate.

I want to calculate:

v_i = f(x_i, y_i, z_i)

For a different set of data (x_i. y_i, z_i) in Simulink.

The block LOOPUP N-D seems to be what I need, but I only get NaN on its output.

I have done this kind of interpolation already in M-code, using GRIDDATAN, and that worked fine.

May it be that I am using the lookup block wrong? I set parameters like this:
Breakpoint 1: x
Breakpoint 2: y
Breakpoint 3: z
Table: griddatan result on x,y,z evaluated on an uniform grid

I am not sure the Table is properly input, as I keep on getting NaN when I should not

Any idea, suggestion, shortcut ?

Thanks

Alvaro Canivell

unread,
Feb 11, 2010, 7:42:04 AM2/11/10
to
Small update here:

I tried creating the following out of my data:
* 3 breakpoints, being of dimension 1x10:
x
y
z

* A table, a 3D diagonal matrix (10x10x10) with all the corresponding values of v on the diagonal of the matrix, and the rest ZERO.

But then I get the following error when I run simulink:
--> Values of BreakpointsForDimension1 in 'canistergasmodel02/Lookup Table (n-D)' must be monotonically
increasing. The problem occurs at the number 578667976 breakpoint. Please change the breakpoint data or use the
fixedpoint tools such as Auto Scaling or fixpoint advisor to determine a different parameter dialog type.

Then I used the 'sortrow' command to sort the 4D set data, but I still get this. For the record, my sorted 4D set of data is:
[x y z v]=

2.0000 23.6667 -91.0000 100.0000
2.0000 28.1667 -92.0000 105.0000
2.0000 27.2000 -88.0000 100.0000
5.0000 27.9000 20.0000 5.0000
5.0000 22.0333 20.0000 5.0000
5.0000 29.5333 20.0000 8.0000
20.0000 27.3000 20.0000 11.0000
20.0000 21.0000 20.0000 5.0000
25.0000 26.3667 20.0000 8.0000
40.0000 29.0000 20.0000 8.0000

First column is sorted, but it is impossible to have x y and z columns sorted simultaneously

So I do not see how to solve the problem, again

Ideas how I may use this lookup n-D block for my purpose?

Alvaro Canivell

unread,
Feb 17, 2010, 11:12:21 AM2/17/10
to
Ok, so I finally found a solution with the help of Matlab guys and a lot of trying. Main points to remember for the future:

- As breakpoints, one must use linearly spaced arrays
- As table, one must use a 3x3 matrix.
- Griddata can not interpolate data out of the convex volume formed by the scattered experimental points.

So this is what I did to get it right:

My experimental data is like this:

x, y, z, v , arrays of 1xn dimension

Which are related to one another in this form: v = f (x,y,z). The function 'f' is UNKNOWN.

I need to evaluate 'v' for different values on the 3D space {x,y,z}.

So I use first create a linearly spaced grid with 'meshgrid' using 3 vectors, defined in my target volume of interest:

x_linspace (1xn)
y_linspace(1xn)
z_linspace (1xn)

Then I use 'griddata3' to evaluate 'v' in this newly created grid, thus getting a 'v_griddata3' matrix which is nxnxn

So now we ALMOST have all the data ready for 'lookupnd' in simulink:

Breakpoints:
x_linspace (1xn)
y_linspace(1xn)
z_linspace (1xn)
Table:
v_griddata3 (nxnxn)

I mean ALMOST, because 'v_griddata3' maybe full of NaN as griddata can not interpolate data out of the convex volume formed by the scattered experimental points. A Table with a lot of NaNs will generate a lot of NaN, which is not desireable.

Therefore, we can use the wonderful 'inpaint_nan3' (check matlab central). This will extrapolate the current values in 'v_griddata3' in order to eliminate all NaN.

That is all. Interpolation must work fine then.

Thanks everybody who helped !

Álvaro

Maxim

unread,
Apr 15, 2016, 6:23:09 AM4/15/16
to
Good job solving this problem.
I'm faced with a similar issue - the only difference is that I have 4-dimensional data. Do you perhaps have some ideas about how to extrapolate the data in 4D case, in order to get rid of NaNs?
Cheers!

EKC

unread,
Sep 8, 2016, 9:49:09 AM9/8/16
to
"Maxim" wrote in message <neqfe7$t09$1...@newscl01ah.mathworks.com>...
> Good job solving this problem.
> I'm faced with a similar issue - the only difference is that I have 4-dimensional data. Do you perhaps have some ideas about how to extrapolate the data in 4D case, in order to get rid of NaNs?
> Cheers!
Hello,

I was wondering if you have figured out a solution to your problem as I am currently facing the same issue with no solution in sight.

Thanks!

Emma

Maxim

unread,
Sep 8, 2016, 12:53:08 PM9/8/16
to
"EKC" <ecu...@aktv8.com> wrote in message <nqrq8f$pje$1...@newscl01ah.mathworks.com>...
Hi Emma,
I inpainted over the NaNs with this tool from File Exchange: http://se.mathworks.com/matlabcentral/fileexchange/27994-inpaint-over-missing-data-in-1-d--2-d--3-d--n-d-arrays
I'm not sure how exactly this approach interpolates things, but it worked like a charm for me. :)
BR, Maxim
0 new messages