How to find the Intersection between curves and yline ?

1 次查看(过去 30 天)
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by