Finding intersection of curve and a line
조회 수: 4 (최근 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!