File Exchange

image thumbnail

Shuffle a vector for multiple times and concatenate them

version 1.0.0.0 (418 Bytes) by Shoaibur Rahman
Shuffle a vector for multiple times and concatenate them

0 Downloads

Updated 28 Jan 2016

View License

Y = shuffleVector(X,N) Shuffle the vector X for N times, and concatenate the each shuffle to generate a new vector Y.

Cite As

Shoaibur Rahman (2019). Shuffle a vector for multiple times and concatenate them (https://www.mathworks.com/matlabcentral/fileexchange/55129-shuffle-a-vector-for-multiple-times-and-concatenate-them), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Jan

RANDPERM is smarter than SORT(RAND).

Jos (10584)

Nice snippet which may be useful for some. Take a look at the help section which is not particularly useful.

Here is a vectorised solution:
[~,ix] = sort(rand(numel(X),N))
Y = X(xi)

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux