Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

save data and use it back in the loop with condition

1 visualización (últimos 30 días)
Kugen Raj
Kugen Raj el 3 de Abr. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
a=abs(randn(1,100));
for n=1:10
count=0;
for angle=0:360
count=count+1;
Xd=(D*cos(angle*pi/180));
Yd=(D*sin(angle*pi/180));
d1(n,count)= sqrt((Yd-y(n))^2+(Xd-x(n))^2);%distance between destination and sensor for 0 to 360 degree.
k(n,count)=((2*pi)/lambda)*(d1(n,count)); %phase lag for each sensor.
yy(n,count)=(exp(-i*k(n,count))*c(n)*a(n)); %weight multiplication to correct the phase lag.
end
end
Y=sum(yy);
YY=abs(Y);
p=20*log10(YY/max(YY));%normalized power in dB;
in the code above, i am creating an array (a) with random values. then i use the array of data to calculate (yy). i test the (yy) value, if the value of (yy) is better than the previous (yy) value, i will use the current (a) array of data to calculate the (yy) value for the next loop. If not i will use the previous (a) value to calculate the next (yy) value. Now the question is, how can I save the (a) value to use it back for the calculation for the next loop. i mean, how can I use the previous (a) value to calculate the (yy) value for the next loop? And, how can I replace the saved (a) value with another new array of (a) values?

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by