Finding intersection of curve and a line

4 visualizzazioni (ultimi 30 giorni)
Jenniluyn Nguyen
Jenniluyn Nguyen il 1 Lug 2019
Risposto: Star Strider il 1 Lug 2019
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!2019-07-01.png

Risposte (1)

Star Strider
Star Strider il 1 Lug 2019
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.

Categorie

Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by