How to find the zero vaue of a plot?

8 views (last 30 days)
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

Accepted Answer

Les Beckham
Les Beckham on 28 Jun 2022
Edited: Les Beckham on 28 Jun 2022
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

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!