How to make this loop fast.

I want to optimised the below given code,
for I=1:1*10^5
y1=Mod_sig*h(1,I)*Theta(1,I);
rx=y1+1*Noise(no_of_points, Nsp,Gain_edfa,h_p,Nu,B);
clear y1
rx_fft=fftshift(fft(rx));
clear rx
obpf_opfd=OBPF.*rx_fft;
clear rx_fft
Obpf_optd=ifft(ifftshift(obpf_opfd));
clear obpf_opfd
De_mod=Delay_demodulation(Obpf_optd,samples_per_bit);
clear Obpf_optd
Elpf_op= lowpass_bessel_filter_output(order,cutoff_frequency,De_mod,Fs);
clear De_mod
Samp_sel=Elpf_op(:,4:samples_per_bit:end);
clear Elpf_op
Th_op=Samp_sel>0;
error=sum(sum(data1~=Th_op));
Err=[Err error];
end
its taking a lot of time.

Answers (1)

madhan ravi
madhan ravi on 31 Oct 2018
Remove all clear commands from the loop and see

1 Comment

thanks for your suggestion but its not working.

Sign in to comment.

Products

Release

R2017a

Community Treasure Hunt

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

Start Hunting!