How to interpolate values of x-axis using y-axis values as reference?
37 views (last 30 days)
Show older comments
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
3 Comments
dpb
on 12 Oct 2015
Show what "didn't work" consists of. If, as Stephen notes, the data are monotonic, there's no difference to interp1. Of course, you have to request a value within the range of y as the input as well as swap the two datasets.
Accepted Answer
Star Strider
on 12 Oct 2015
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')
4 Comments
More Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!