Replace data inside a loop.

조회 수: 1 (최근 30일)
Kugen Raj
Kugen Raj 2012년 4월 5일
for N=10:10
count2=count2+1;
for ii=1:last
a=abs(rand(1,N))
for n =1:N
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
Y=sum(yy);
YY=abs(Y);
p=20*log10(YY/max(YY));%normalized power in dB.
end
end
end
I want to replace the (a) value for each loop of (for ii=1:last) loop. i want to replace the new (a) value with the old (a) value. how can I do that?
  댓글 수: 1
Jan
Jan 2012년 4월 5일
RAND replies non-negative values only. Therefore ABS() is not required.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2012년 4월 5일
Please explain how the first a value is defined, if you replace each a by the former value.
Usually such problems are solved like this:
aOld = 0;
for i = 1:100
a = rand;
% Your computations here, e.g.:
disp(a - aOld);
...
aOld = a;
end
  댓글 수: 3
Jan
Jan 2012년 4월 5일
Again: The ABS() is not required here.
Does this mean, that your problem is solved?
Kugen Raj
Kugen Raj 2012년 4월 5일
well, that is because i want the a value to be a positive value. If i don't use abs(), i would get a negative value too.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by