Matching X and Y co-ordinated from the reference xy

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
SatyaPrakash Gupta
SatyaPrakash Gupta il 9 Dic 2019
Yes i would like to return all the matched value in an array.
Please note : the dimension of X will have different size

Accedi per commentare.

Risposta accettata

Rik
Rik il 9 Dic 2019
Modificato: Rik il 9 Dic 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 Commenti
SatyaPrakash Gupta
SatyaPrakash Gupta il 9 Dic 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 il 9 Dic 2019
Modificato: Rik il 9 Dic 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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Prodotti


Release

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by