i have to arrays:
a linear one;
x = array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. , 1.1, 1.2, 1.3, 1.4])
And a corresponding result which is a non-linear one;
y = array([ 13.07, 13.7 , 14.35, 14.92, 15.5 , 16.05, 16.56, 17.12,
17.62, 18.08, 18.55, 19.02, 19.45, 19.88, 20.25])
Now: I want to convert y to a linearly spaced array and find the corresponding interpolated values of x.
i.e. find x when
y = array([ 13. , 13.5, 14. , 14.5, 15. , 15.5, 16. , 16.5, 17. , 17.5, 18. , 18.5, 19. , 19.5, 20. ])
Thanks in advance.
I use the following method using the interp function in numpy:
ynew = np.linspace(np.min(y), np.max(y), len(y))
xnew = np.interp(ynew, y, x)
i.e. exchanging x and y in the np.interp function.
Is this always correct ? or will it break down for some condition.