OK, how do you need to compare the first column of X with the first column of Y? Correlation? length of difference-vector? Angle between vectors? If you describe what you need to do answers will come that much easier.
After a little bit of inspection ot seems you need to find the most identical component? If this is so, I suggest that you have a look at min, abs, using those two function would help you solve the task for one element of X and one column of Y Z and A? Once you worked that out use loops to repeat that step for all components in X.