Repeat resampling with replacement process several times
1 view (last 30 days)
Show older comments
stelios loizidis
on 21 Nov 2022
Commented: stelios loizidis
on 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 Comments
Accepted Answer
VBBV
on 21 Nov 2022
Edited: VBBV
on 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 Comments
VBBV
on 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
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!