How to find the zero vaue of a plot?

5 次查看(过去 30 天)
I have 2 vetors X ,Y plotted Y vs X.
The plot it's made by 2 differrent straight line.
I would like to find the "zero- value"
X=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
Y=[-0.88 -0.7489 -0.6178 -0.4867 -0.3556 -0.2245 -0.0934 0.0378 0.1689 0.3 0.4311 0.5182 0.6053 0.6924 0.7795 0.8666 0.9537 1.0408 1.1279 1.2150 1.3022];
plot(A,B
Aussuming that Y=f(X) i would like to find Xo for having Y(Xo)=0
I have not the function equation, and i know it would be easy to directly find it in this case, but i am looking for a way to find the 'zero' value of the x-axis for any 2 set of numbers X, Y

采纳的回答

Les Beckham
Les Beckham 2022-6-28
编辑:Les Beckham 2022-6-28
X=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
Y=[-0.88 -0.7489 -0.6178 -0.4867 -0.3556 -0.2245 -0.0934 0.0378 0.1689 0.3 0.4311 0.5182 0.6053 0.6924 0.7795 0.8666 0.9537 1.0408 1.1279 1.2150 1.3022];
plot(X, Y)
% Find the value of x corresponding to Y = 0
x0 = interp1(Y, X, 0)
x0 = 6.7119
hold on
plot(x0, 0, 'r*')
grid on

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by