How to find the Intersection between curves and yline ?

1 vue (au cours des 30 derniers jours)
Jenifer NG
Jenifer NG le 22 Août 2022
Commenté : Jenifer NG le 22 Août 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

Réponse acceptée

Chunru
Chunru le 22 Août 2022
Modifié(e) : Chunru le 22 Août 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)

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by