How to randomly repeat an array elements?
Show older comments
I have a 1x4 array as,
P = [1, -1, j, -j]
How to form a New " 1x16 random array " using only four elements of 'P' ?
This new 1x16 array should have random arrangement of elements of 'P',(i.e.,irrespective of order of elements of 'P')
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 20 Oct 2013
P = [1, -1, j, -j];
a=perms(1:4);
id=randi(size(a,1),4,1);
idx=a(id,:);
out=P(idx(:))'
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!