MATLAB: Comparing two separate for loops

for loopintersect

i have two seperate for loops
i need to compare them to display what is repeated ONLY in the both of them
ex.
Z =
0.0024 0.0019 0.0015 0.0012 0.0010 0.0007 0.0005 0.0003 0.0002
Y =
0.0031 0.0024 0.0019 0.0015 0.0012 0.0010 0.0007 0.0005 0.0003 0.0002
the asnwer should be
X=
0.0024 0.0019 0.0015 0.0012 0.0010 0.0007 0.0005 0.0003 0.0002

Best Answer

Use intersect():
Z =[0.0024 0.0019 0.0015 0.0012 0.0010 0.0007 0.0005 0.0003 0.0002]
Y =[0.0031 0.0024 0.0019 0.0015 0.0012 0.0010 0.0007 0.0005 0.0003 0.0002]
X = intersect(Z, Y)