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

1 Download

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 (2021). 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 (3)

in the comment below, it should be X(ix)

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!