Extracting points from a plot that do not appear in the original data

2 次查看(过去 30 天)
I was wondering if it is possible to extract information from a plot that only 'exists' in the plot itself, not the underlying data. For example, in the attached image I would like to extract the data point where the two lines intersect - however this does not exist in the original data - the closet 'real' points plotted in yellow.
I know I could take a ginput and have the user manually click on the intersection point, but was wondering if it is possible to automate this?
Best,
JoeMATLAB_Q_example_plot_non_value.PNG

采纳的回答

Adam Danz
Adam Danz 2019-3-19
编辑:Adam Danz 2019-3-21
Here's a demo
% Order is important!
% Line 1 is defined by the first two values. Line 2 is defined by second two values.
x = [5, 6, 5, 6]; % x coordinates of 4 points
y = [4.5, 6.5, 6.5, 4.5]; % y coordinates of 4 points
% Define function that calculates intersection point
getIntersect = @(x,y)[x(1)*y(2)-x(2)*y(1), x(3)*y(4)-x(4)*y(3)] / [y(2)-y(1), y(4)-y(3); -(x(2)-x(1)),-(x(4)-x(3))];
% xyIntersect is a [1 x 2] vector if (x,y) coordinates of intersection.
xyIntersect = getIntersect(x,y);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by