How to find the Intersection between curves and yline ?

4 visualizaciones (últimos 30 días)
Jenifer NG
Jenifer NG el 22 de Ag. de 2022
Comentada: Jenifer NG el 22 de Ag. de 2022
Hi All,
I want to find the Intersection value of these curves and yline(0.1).
Could Anyone please help me ?
This is my code:
load matlab
lst = {'0.54','0.55','0.56','0.57','yline'}
plot(m4)
yline(0.1,LineWidth=1.5,LineStyle="--")
legend(lst)
Thanks and Regard!
Han

Respuesta aceptada

Chunru
Chunru el 22 de Ag. de 2022
Editada: Chunru el 22 de Ag. de 2022
load matlab
lst = {'0.54','0.55','0.56','0.57','yline'}
lst = 1×5 cell array
{'0.54'} {'0.55'} {'0.56'} {'0.57'} {'yline'}
plot(m4)
yline(0.1,LineWidth=1.5,LineStyle="--")
legend(lst)
for i=1:size(m4, 2)
F = griddedInterpolant(1:size(m4, 1), m4(:, i));
[~, x0] = min(abs(m4(:, i) - 0.1)); % coarse estimate
x(i) = fsolve(@(x) F(x)-0.1, x0); % finer solution
end
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved at initial point. fsolve completed because the vector of function values at the initial point is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
x
x = 1×4
52.9828 59.1347 66.0000 69.8486
hold on
xline(x)

Más respuestas (0)

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by