Hello. I would like to remove the for loops from this script. Could anyone provide me information on how to do it? The loop takes a long time to run. Thank you!
n=12000;
resamples=5000;
Z=zeros(1,5);
Y=zeros(resamples,5);
for j=1:resamples
for k=1:n
r=randi(n);
Z=Z+B(r,:);
end
Y(j,:)=Z;
end

1 Kommentar

Matt J
Matt J am 25 Okt. 2013
Bearbeitet: Matt J am 25 Okt. 2013
Please format your code readably, using the
toolbar button.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Matt J
Matt J am 25 Okt. 2013

0 Stimmen

idx=randi(n,n*resamples,1);
Y=sum(reshape(B(idx,:),n,[]),1);
Y=reshape(Y,resamples,[]);

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 25 Okt. 2013

Kommentiert:

am 25 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by