Finding X values of multiple lines for a given Y value

조회 수: 2 (최근 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 CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by