A=[1.02425546496901 1.25358084802804 1.17951024589869 1.67572050678079 1.36894578489338 1.6749531972447 1.72228602412244 1.57044649311883 1.13258989974403 1.90017865546025; 1.50659089719153 1.83620274208373 1.54085325182511 1.7648613516281 1.53236552752797 2.00265451589403 1.63189442288142 1.52571664681234 1.61703687407616 1.82597937814431]; B=[-0.364218237058624 -0.627935085190556 -0.435555596054787 -0.97890906944334 -0.368512531286445 -0.558137538884114 -0.254487941788666 -0.300780054401997 -0.61814596238125 -0.570864465939227 -0.683820512711681 -0.471135644946428; -0.820567174888604 -0.905539415326849 -0.726200531441377 -0.995112554677464 -0.343980731337428 -0.332428485029845 -0.977633932802877 -0.584977211064341 -0.966664915591615 -0.556292501691081 -0.519141532920073 -0.964541521774489]; x=equalDistance(A, B); format long; x % Plotting plot(A(1,:), A(2,:), 'o', B(1,:), B(2,:), 'o'); grid on; axis image line(x, 0, 'marker', 'o', 'color', 'k'); legend('Set A', 'Set B', 'x', 'location', 'northOutside', 'orientation', 'horizontal'); title(['x =', mat2str(x)]);