I would like to permute a row vector, but without using perms(), permute() and so forth. I was wondering whether the following code answers these requirements. I mean, am I somewhat "cheating" by using randi()? I'd also appreciate any comments on the algorithm in general (although I know the function works well).
function Y = ex(X) Y = zeros(1,length(X));for i = 1:length(X) d = randi(length(X)); Y(i) = X(d); X(d) = [];end
Best Answer