How to interpolate values of x-axis using y-axis values as reference?
29 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Daniyal Ali
il 12 Ott 2015
Modificato: Stephen23
il 14 Ott 2015
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 Commenti
dpb
il 12 Ott 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.
Risposta accettata
Star Strider
il 12 Ott 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!