MATLAB Answers

Solving Equation Generated by pchipinterp method

3 views (last 30 days)
Frank
Frank on 5 Aug 2011
Edited: John D'Errico on 8 Oct 2020
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 Comments

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 8 Oct 2020
Edited: John D'Errico on 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 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by