
How Can speed up "for" loop ?
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
See Also
Categories
Find more on QPSK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!