
How Can speed up "for" loop ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
How can I speed up following 'for' loops? Help me please.Thanks.
N=1000 > 30sec , N=1000 > 10min , N=100000 > 5hr up can't produce result
N = 100000;
B= 0.3;
Pf=linspace(0.9,0.1,n);
data = randi([0,1],N, 1);
for k=1:2
Lambda= (1+sqrt(2/N)*qfuncinv(Pf))*var(wgn(N, 1,0) .* sqrt(p(k)/2));
for i = 1:length(Pf)
Nd_BPSK=0;
for j=1:N
noise_BPSK = wgn(N, 1,0) .* sqrt(p(k)/2);
h_BPSK = raylrnd(B, N, 1);
receive_BPSK = abs(h_BPSK).*send_BPSK + noise_BPSK;
T_simu_BPSK(i)=sum(abs(receive_BPSK).^2)/N;
if T_simu_BPSK(i) > Lambda(i)
Nd_BPSK=Nd_BPSK+1;
end
end
Pd_simu_BPSK(i,k)=Nd_BPSK/j;
end
for i = 1:length(Pf)
Nd_QPSK=0;
for j=1:N
noise_QPSK = wgn(N/2, 2, 0) .* sqrt(p(k)/2);
h_QPSK = raylrnd(B, N/2, 2);
receive_QPSK = abs(h_QPSK).*send_QPSK + noise_QPSK;
receive_QPSK2=reshape(receive_QPSK,N,1);
T_simu_QPSK(i)=sum(abs(receive_QPSK2).^2)/N;
if T_simu_QPSK(i) > Lambda(i)
Nd_QPSK=Nd_QPSK+1;
end
end
Pd_simu_QPSK(i,k)=Nd_QPSK/j;
end
end
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur QPSK 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!