

That being said, if you would like to add extrapolation abilities to the interp1d method, see this answer (since I'm a Matlab guy and not a Python guy (yet)). This may be correct but should be considered carefully before taking as gospel. The extrapolation indicates that the y-value turns over. For the values you quotes, Matlab's 'cubic'/ 'pchip' extrapolation produces the graph:

That being said, I would be wary to call Matlab's (or any program's) default extrapolation values "real values", as extrapolation can be quite difficult and easily generate anomalous behavior. This is different from Matlab's default which is to extrapolate using the requested interpolation method ( docs). Why?"īecause the set of sample points you give it ( Freq_ref) has a lower bound of 20 and interp1d will assign values for points outside the sample set the value of fill_value if bounds_error is False ( docs).Īnd since you requested an interpolation for frequency values from 0 to 19, the method assigned them NaN. Interp1d "outputs the beginning values of array as NaN. How can I avoid this and actually have real values like matlab does with interp1d?

The following is the same outputted in maltab for the first 20 values: -58.0424562952059 The first 20 values in WdB are : 00000 = nan WdB = interpolate.interp1d(Freq_ref,W_ref,kind='cubic',axis=-1, copy=True, bounds_error=False, fill_value=np.nan)(FreqVector)
#Python matlab interp1 code#
I have the following code that I am working on in python with interp1d and it seems that the output of the interp1d times the query points outputs the beginning values of array as NaN.
