Finding X values of multiple lines for a given Y value

3 ビュー (過去 30 日間)
Theodore McCarthy
Theodore McCarthy 2021 年 4 月 9 日
コメント済み: Theodore McCarthy 2021 年 4 月 9 日
I'm looking for a way to determine the x-values of each curve on this plot at a given y-value. The screen shot shows the curves, and I want to calculate x-values along y = 75.
I have tried using an index type approach however this just returns an empty double row vector. I'm aware I can just read off the graph however it would be good to have a code based solution for if the values that affect the curves change.
constant_torque = 75.000
index_50 = find(t_ind50 == constant_torque);
nm_50 = nm_lv(index_50)
Where t_ind50 is the curve produced by an iterative code
for i1 =1:1:50001
t_ind50(i1) = (3 * voltage_l_50^2 * r2 / s(i1)) / (w_sync * ((r_th + r2/s(i1))^2 + (x_th + x2)^2) );
and nm_lv is calculated using:
s = (0:1:50000) / 50000; % Slip
s(1) = 0.001;
nm_lv = (1 - s) * n_sync;
Many thanks

採用された回答

Alan Stevens
Alan Stevens 2021 年 4 月 9 日
Never test for exact equality when dealing with floating point numbers. Use something like
index_50 = find(abs(t_ind50-constant_torque)<10^-8);

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by