Finding intersection of curve and a line
2 ビュー (過去 30 日間)
古いコメントを表示
Hello! I apologize if that has been asked before - I tried finding an answer but I didn't really understand any of them/many of them didn't work because it wasn't for this situation specifically.
I have this graph (see below), with two y lines on them. I was hoping to find the coordinate intersection of the bottom line (let's call it secondY) and the exponential curve (which we can call curve). I would then like to draw an x line wherever the intersection x value is. What would be the simplest way to do this?
I appreciate your help, thank you!

0 件のコメント
回答 (1 件)
Star Strider
2019 年 7 月 1 日
Your ‘curve’ has noise between x=0 and x=200 or so. You will likely need to exclude that region.
One option is to use interp1, for example:
xq = interp1(curve(idxrng), x(idxrng), lineval);
where ‘idxrng’ are the index values that exclude the noise, and ‘lineval’ is whatever y-value the line has.
Another option is to use polyfit to approximate the exponentially-descending part of the curve:
p = polyfit(x(idxrng), y(idxrng), 3);
xq = roots(p - lineval);
Without your data, it is not possible to write specific code.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!