2D LUT (extrapolation) Simulink vs interp2

Hi,
I am trying to "converts" a Simulink model into a matlab script/function, but I stumbled upon the 2D Look Up table conversion.
The interp2 works fine if input values lies inside the table (interpolation). However when the one/more input values lie outside the look-up table, interp2 per default returns NaN. The NaN can be substituted by any scalar number. The 2D-LUT block needs to be converted is set to do linear extrapolation when the input values fall outside the table.
Is there any default function to do 2D-linear-extrapolation in Matlab? preferably with same working principle as in 2D-LUT block in Simulink?

댓글 수: 1

Ilham Hardy
Ilham Hardy 2015년 4월 15일
Another angle:
Is there anyway to retrace the calculation done by 2D-lookup table in Simulink? Does 2D-LUT block calls specific Matlab function?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sebastian Castro
Sebastian Castro 2015년 4월 15일

0 개 추천

Looks like interp2 is designed to return NaNs by default unless your interpolation method is 'spline' .
You can change this by include the last 'scalar' argument after the interpolation method. For example,
Vq = interp2(V,Xq,Yq,'linear','scalar')
- Sebastian

댓글 수: 3

Ilham Hardy
Ilham Hardy 2015년 4월 16일
Sebastian,
I am not quite sure that I get your point. If i understand correctly, the 'scalar' argument is actually one scalar number/constant to replace NaN when interp2 extrapolates. It doesn't really extrapolates.
What I need, or what the 2D lookup table does , is actually a 2D extrapolation instead of returning NaN or just one scalar number.
Sebastian Castro
Sebastian Castro 2015년 4월 16일
편집: Sebastian Castro 2015년 4월 16일
Whoops! Didn't notice that part -- that it's a single scalar value.
What about griddedInterpolant? That one definitely has various extrapolation methods.
There are two examples at the end of the above page for 2-D interpolation and 1-D extrapolation.
- Sebastian
Is there an accepted answer for this question? I also have the same problem of extrapolating, however, I couldn't find the solution from those pages.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2015년 4월 15일

댓글:

2018년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by