Finding intersection of curve and a line

3 visualizaciones (últimos 30 días)
Jenniluyn Nguyen
Jenniluyn Nguyen el 1 de Jul. de 2019
Respondida: Star Strider el 1 de Jul. de 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

Respuestas (1)

Star Strider
Star Strider el 1 de Jul. de 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.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by