How do I generate 1000 random rows from an array only once, so that if I run the program again, it will still be the same set of randomly generated number previously

3 visualizzazioni (ultimi 30 giorni)
% Generate a matrix named foo
foo = randn(10000,2);
% draw 1000 random samples
index = randsample(1:length(foo), 1000);
bar = foo(index,:);
Suppose I have the code above, I only want to generate 1000 random rows once. I do not want a different set of 1000 random row everytime I run the program again. Please help. Thank you

Risposta accettata

Stephen23
Stephen23 il 31 Gen 2020

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by