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

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Adam Danz
Adam Danz il 19 Mar 2019
Modificato: Adam Danz il 21 Mar 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);

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by