Numpy : Valueerror: Object Of Too Small Depth For Desired Array
I am trying to convert a MATLAB code to Python where I am stuck of how to import this line to Python: YDFA_xa_p = interp1(data(:,1),data(:,2),YDFA_lam_p*1e9,'linear')*1e-24; Now f
Solution 1:
When I use the same sort of numbers in Octave I get a similar error:
octave:32> interp1([2,2,2,2],[3,3,3,3],900)
warning: interp1: multiple discontinuities at the same X value
error: mkpp: at least one interval is needed
You've given it one point (repeatedly) and are asking it to interpolate some value way off in left field.
A correct sample use is:
octave:32> interp1([1,2,3,4,5],[3,3.5,2,2.5,1],2.33,'linear')
ans = 3.0050
the equivalent Python (note different order of variables):
In [364]: np.interp(2.33,[1,2,3,4,5],[3,3.5,2,2.5,1])
Out[364]: 3.005
Read help(np.interp)
to see more about its inputs.
Post a Comment for "Numpy : Valueerror: Object Of Too Small Depth For Desired Array"