Find x for known y from fit
Mostra commenti meno recenti
Hi all
I would like to find values of x when y values are known using fzero. Assuming I have the following data:
x = [1 3 6 8 14 19 20 22];
y = [0.3 0.5 0.8 0.85 1 1.05 1.5 1.9];
xf=linspace(0,22,300)
yf=interp1(x,y,xf,'spline');
plot(x,y,'LineStyle','none','Color','k', 'MarkerSize',4 ,'Marker','square');
hold on
plot(xf,yf,'-r')
To find for example the value of x at yy=1.5 I used:
xdatax=fzero(@(xi)interp1(x,y,xi,'spline')-yy,5)
it works and it gives 3. But changing the value of yy (e.g.yy=1.5) gives xdata=-5.04 which is worong!!!
Does anyone know why it gives wrong results for some yy values? I appreciate your help and thanks..
Adam
1 Commento
Adam
il 4 Ott 2017
Modificato: Walter Roberson
il 4 Ott 2017
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Spline Postprocessing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!