Matching X and Y co-ordinated from the reference xy

12 ビュー (過去 30 日間)
SatyaPrakash Gupta
SatyaPrakash Gupta 2019 年 12 月 9 日
編集済み: Rik 2019 年 12 月 9 日
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 件のコメント
darova
darova 2019 年 12 月 9 日
What about 1 and 4?
SatyaPrakash Gupta
SatyaPrakash Gupta 2019 年 12 月 9 日
Yes i would like to return all the matched value in an array.
Please note : the dimension of X will have different size

サインインしてコメントする。

採用された回答

Rik
Rik 2019 年 12 月 9 日
編集済み: Rik 2019 年 12 月 9 日
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 件のコメント
SatyaPrakash Gupta
SatyaPrakash Gupta 2019 年 12 月 9 日
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 2019 年 12 月 9 日
編集済み: Rik 2019 年 12 月 9 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by