Matching X and Y co-ordinated from the reference xy

2 vues (au cours des 30 derniers jours)
SatyaPrakash Gupta
SatyaPrakash Gupta le 9 Déc 2019
Modifié(e) : Rik le 9 Déc 2019
Hi,
I have list of XY coordinates i.e XY points for the given figure.
further i have extracted the required XY coordinates and now i want to match my current XY values present in reference XY coordinates, is it possible ?
could you please do help me here.
e.g
X = [ 1,2,3,4,5,6,7.6 , 8.9, 5.7 ..]
X = [1, 4,6,9,3,7.6,5.3.5.7... ]
so i want to compare this and get the result with the matched values i.e
final X = [7.6,5.7]
is there a way to do this ?
thank you.
  2 commentaires
darova
darova le 9 Déc 2019
What about 1 and 4?
SatyaPrakash Gupta
SatyaPrakash Gupta le 9 Déc 2019
Yes i would like to return all the matched value in an array.
Please note : the dimension of X will have different size

Connectez-vous pour commenter.

Réponse acceptée

Rik
Rik le 9 Déc 2019
Modifié(e) : Rik le 9 Déc 2019
Although you can solve this with the ismember function, you are actually looking for the intersect function:
X = [1,2,3,4,5,6,7.6,8.9,5.7];
Y = [1,4,6,9,3,7.6,5.3,5.7];
X_new=intersect(X,Y)
  3 commentaires
SatyaPrakash Gupta
SatyaPrakash Gupta le 9 Déc 2019
Hi Rik,
it will not resolve the problem because as i mentioned that i am storing the x and y values of the marked using iamfreehand() so it gives only the boundy values not the values inside the boundries, therefore i cannot use this intersect function.
could you let me know how to resolve it?
thank you
Rik
Rik le 9 Déc 2019
Modifié(e) : Rik le 9 Déc 2019
So you have a list of coordinates that form the boundary of an object? If you have a closed loop, you can use the inpolygon function to find all grid points inside your trace.
%generate an outline
u=20;
t=linspace(0,2*pi,6);x=u+u*cos(t);y=u+20*sin(t);
[X,Y]=ndgrid(1:(2*u));
L=inpolygon(X(:),Y(:),x,y);
X_in=X(L);
Y_in=Y(L);
figure(1),clf(1)
plot(x,y,'b')
hold on
plot(X(L),Y(L),'r*')
plot(X(~L),Y(~L),'r.')
axis([0 2*u+1 0 2*u+1]) %fit axis to displayed data
daspect([1 1 1])%set aspect ratio to 1

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by