How can i randomly pick a number from the given following matrix below?
A=[0.06 0.47 0.47]
I just want to randomly pick a number from the matrix above. I am doing this in matlab enviornment. please help. Also, Is it possible assume a variable in matlab that tends to zero, like we do in limits?
You can use the randperm function to create a double array of random integer values that have no repeated values. For example, r4 = randperm(15,5);
To sample random integers without replacement, use randperm or datasample . To randomly sample from data, with or without replacement, use datasample .
If your matrix is M
then to pick a random element with uniform probability you can use randi
:
M(randi(numel(M)))
Yes, using randi:
A(randi(numel(A)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With