how to generate vector by selecting from another vector?
Show older comments
There is a matrix, "a" that is n by 1. I need to generate another matrix with this size (n by r), by selecting randomly from "a". I need a function like unifrnd(min, max, [d f]), but selecting from another matrix. Would you please guide me in this regard?
Thanks in advance,
Mina
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 6 Aug 2016
%-----------Example-------------
n=10
r=4
A=randi(10,1,n)
%------The code----------
AA=sort(A)
a = AA(1);
bb=AA(2:end)
b=repmat(bb,r,1)
out = unifrnd(a,b)
1 Comment
mina movahed
on 6 Aug 2016
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!