Sample from the previous sample, whole rows.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
My goal here is to combine these two codes that I have. The first code uses randsample from the statistics library, and I can use this, but I think it would be easier all around to try to incorporate the second block of code.
The first set of code works well, except that I am having trouble modifying it to sample whole rows of code. The second block of code does this, but only once.
Basically, I would like to take samples over and over. For example I want to find m2, which is sampled from m1. Then find m3, which is sampled from m2. So on and so forth. Ideally it would use the code below, and something that I could take n samples.
Ideally I would be able to use the things that I already have, but if there is a better way to go about it, then by all means.
Thanks in advance.
First Block:
x{1} = randsample(99, 15)';
for k1 = 2:10
x{k1} = randsample(x{k1-1},15);
end
Second Block:
m1 = rand(1000,10);
k = randi(1000,1, 1000);
m2 = m1(k(1:1000),:);
0 commentaires
Réponses (1)
dpb
le 12 Août 2015
Your second is simply another way for writing
m2=m1(randperm(1000),:)
If you're not regenerating m1 but simply rearranging, then one could simply preallocate a resulting array of (N,size(m1,2)) and populate it with the above in a loop or with accumarray or the like.
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!