Solving Equation Generated by pchipinterp method

13 ビュー (過去 30 日間)
Frank
Frank 2011 年 8 月 5 日
編集済み: John D'Errico 2020 年 10 月 8 日
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.

回答 (1 件)

John D'Errico
John D'Errico 2020 年 10 月 8 日
編集済み: John D'Errico 2020 年 10 月 8 日
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:

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by