
Solving Equation Generated by pchipinterp method
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have an array of data which I fitted a curve to using the fit function and pchipinterp method, generating a cfit variable. I know that the line y = (a specific scalar value) will cross the fitted line/function 4 times. How can I solve for those 4 x-coordinates given a specific y-value? Thanks.
0 commentaires
Réponses (1)
John D'Errico
le 8 Oct 2020
Modifié(e) : John D'Errico
le 8 Oct 2020
The simplest way to do this is to use my SLM toolbox.
x = sort(rand(1,20));
y = rand(1,20);
spl = pchip(x,y);
fnplt(spl)
yline(0.3);

What are the x locations where this curve crosses 0.3? There should be 7 such points based on what we see in the figure.
xsol = slmsolve(spl,0.3)
xsol =
Columns 1 through 4
0.0856060691907258 0.179689798032185 0.287680862853776 0.374467025155671
Columns 5 through 7
0.637324302388667 0.644738455928051 0.984815754063193
You can download my SLM toolbox from the File Exchange, here:
0 commentaires
Voir également
Catégories
En savoir plus sur Fit Postprocessing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!