Extracting points from a plot that do not appear in the original data
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joe_Z
am 19 Mär. 2019
Bearbeitet: Adam Danz
am 25 Mär. 2019
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,
Joe
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 19 Mär. 2019
Bearbeitet: Adam Danz
am 21 Mär. 2019
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);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!