How to find the Intersection between curves and yline ?

1 回表示 (過去 30 日間)
Jenifer NG
Jenifer NG 2022 年 8 月 22 日
コメント済み: Jenifer NG 2022 年 8 月 22 日
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

採用された回答

Chunru
Chunru 2022 年 8 月 22 日
編集済み: Chunru 2022 年 8 月 22 日
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)
  1 件のコメント
Jenifer NG
Jenifer NG 2022 年 8 月 22 日
it works nice thanks bro!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by