How to find the zero vaue of a plot?

6 ビュー (過去 30 日間)
Pietro Fiondella
Pietro Fiondella 2022 年 6 月 28 日
編集済み: Les Beckham 2022 年 6 月 28 日
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 Center および File ExchangeSurface 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