Repeat resampling with replacement process several times
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
stelios loizidis
le 21 Nov 2022
Commenté : stelios loizidis
le 21 Nov 2022
Hello,
I have the below code for resampling with replacement.
res1 = [];
res2 = [];
% centerd matrix size:2X7
cen1=centered(1,:);
cen2=centered(2,:);
for j=1:7
res1_temp=cen1(randi(7,1));
res1= [res1 res1_temp];
%
res2_temp=cen2(7,1));
res2= [res2 res2_temp];
end
res_total=[res1; res2]; % 2X7
Now I have to repeat this process 170 times because centered matrix size is 170X7. That is, must have
re1=[];
res2=[];
.......
res170[];
......
res_total=[res1;res2,.....
res170];
and the res_total should be 170X7. How can I as easy as possible?
0 commentaires
Réponse acceptée
VBBV
le 21 Nov 2022
Modifié(e) : VBBV
le 21 Nov 2022
res1 = [];
res2 = [];
centered = rand(170,7)
% centerd matrix size:2X7
% cen1=centered(1,:);
% cen2=centered(2,:);
for j=1:85
cen1 = centered(j,:);
res1(j,:) = cen1;
%
cen2 = centered(j+85,:);
res2(j,:) = cen2;
end
res_total=[res1; res2] % 2X7
3 commentaires
VBBV
le 21 Nov 2022
May be you mean this instead
% res1 = [];
% res2 = [];
centered = rand(170,7);
for j=1:170
res_total(j,:)=centered(randi(j),:);
end
res_total
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!