Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Joe_Z
Joe_Z le 19 Mar 2019
Modifié(e) : Adam Danz le 25 Mar 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,
JoeMATLAB_Q_example_plot_non_value.PNG

Réponse acceptée

Adam Danz
Adam Danz le 19 Mar 2019
Modifié(e) : Adam Danz le 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);

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by