In MATLAB, I have a set of P numbers. I would like to generate a random array of size N from this set.
P
N
For the sake of example, let say I h
You should use datasample,
datasample
y = datasample(data,k) returns k observations sampled uniformly at random, with replacement, from the data in data.
y = datasample(data,k)
k
data
a = [1,4]; datasample(a,5)
Depending on the usage, you might consider using,
datasample(unique(a),5)