2-D, 3-D, n-D data interpolation - Is it possible to extrapolate?

1 次查看(过去 30 天)
Hello,
I'm having the following situation, I have a 2-D Look-up Table in Simulink using the below data.
row_index = [5 25 35]
col_index = [-20 -3 0 5 40]
table_data =
3.0000 1.0000 0 1.5000 2.0000
3.0000 1.0000 0 1.5000 2.0000
3.0000 1.0000 0 1.5000 2.0000
What I'm trying to do is to have the same result (as the 2-D Look-up Table output from Simulink) using Matlab code/functions. I've tried using interp2, but if the values are extrapolated/out of rage, I get a NaN. I'm using version 7.13 (Matlab 2011) and I don't know if is there a solution for this.
For example interp2(col_index,row_index,table_data,-20,5) returns 3 witch is correct.
But if I use interp2(col_index,row_index,table_data,5,-20) returns NaN witch is also correct according to the function description, but in Simulink the 2-D Look-up Table returns 1.5
I'm asking you if is there a solution to get the same result as the 2-D look-up table from simulink. And the same for 3-D or n-D.
Thanks,
Alex

回答(1 个)

Sean de Wolski
Sean de Wolski 2012-10-31
You can set the 'ExtrapVal' to be non-nan:
Of course this is dangerous:
You may also like one fo the FEX extrapolation tools.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by