MATLAB: How can select elements randomly from two matrixes but the same position

MATLAB

ex: A= [1 2 3 4], B= [9 7 6 5] if select 2 in A must select 7 in B 0r 3 in A must 6 in B.
Thanks for help

Best Answer

N = length(A);
pos=randsample(1:N,1);select position randomly
A(pos)
B(pos)