MATLAB: Problem with looping: the loop does not stop

loopigmatlab2014

Hello!
I have a problem that I have built a simple loop, which does not stop while running the code. Does anyone know what could be the issu? I have Matlab 2014.
Lw=106.5
hs=80
hr=1.5
a_air=0.0001
La=zeros(1,8000)
d=1:8000
for i=1:8000
if i<=1000
La(i)=Lw - 8 - 20*log(i) - 0.005*i
else
deltaLa=10*log(10^(Lw/10)) - 10*log(10^((Lw-sqrt(i)*a_air)/10))
La(i)=Lw - 8 - 20*log(i) - deltaLa + 10*log(i/1000)
end
end
Thank you!

Best Answer

%%% you can try this it work good %%%%
clc
clear
Lw=106.5
hs=80
hr=1.5
a_air=0.0001
d=1:8000
La=[];
for i=1:8000
if i<=1000
La=[La; Lw - 8 - 20*log(i) - 0.005*i];
else
deltaLa=10*log(10^(Lw/10)) - 10*log(10^((Lw-sqrt(i)*a_air)/10))
La=[La;Lw - 8 - 20*log(i) - deltaLa + 10*log(i/1000)];
end
end