2D LUT (extrapolation) Simulink vs interp2
8 visualizzazioni (ultimi 30 giorni)
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?
Sebastian Castro il 15 Apr 2015
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')