Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

save data and use it back in the loop with condition

4 Ansichten (letzte 30 Tage)
Kugen Raj
Kugen Raj am 3 Apr. 2012
Geschlossen: MATLAB Answer Bot am 20 Aug. 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?

Antworten (0)

Diese Frage ist geschlossen.

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by