MATLAB: Hi,Is there anyone who could give an idea how to create a permutation vector

permutation vectorvectors

Like,every time the loop constructs,the vector would change.
For example V1=[1 2 3 5 4]; V2=[2 3 1 5 4] and go on?

Best Answer

V1=[1 2 3 5 4]
n=numel(V1)
idx=randperm(n)
V2=V1(idx)
Related Question