Repeat resampling with replacement process several times
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
VBBV
2022년 11월 21일
편집: VBBV
2022년 11월 21일
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
VBBV
2022년 11월 21일
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!