Finding X values of multiple lines for a given Y value
3 views (last 30 days)
Show older comments
Theodore McCarthy
on 9 Apr 2021
Commented: Theodore McCarthy
on 9 Apr 2021
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
0 Comments
Accepted Answer
Alan Stevens
on 9 Apr 2021
Never test for exact equality when dealing with floating point numbers. Use something like
index_50 = find(abs(t_ind50-constant_torque)<10^-8);
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!