MATLAB: How to interpolate values of x-axis using y-axis values as reference

interpolation

I want to do interpolation. I am using the following code
yreq = interp1(x,y,xreq)
This code gives me the value of the parameter on y-axis when i give it the value of x-axis. What i want is to find the value of the x-axis while giving it the value of y-axis. Can it work? I tried switching the x and y axes but it didn't work. Any help will be appreciated. Thanks

Best Answer

If your y data are strictly monotonically increasing (as interp1 requires, since you are using it to interpolate your x data), one possibility to explain the reason ‘it didn’t work’ is that you are asking it to extrapolate.
Try this:
xreq = interp1(y,x,yreq,'linear','extrap')