필터 지우기
필터 지우기

check and compare the result in each loop

조회 수: 1 (최근 30일)
Kugen Raj
Kugen Raj 2012년 4월 4일
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);
Based on the code above, I'm doing the for loop for (1:10). Now, I need to check result of YY in each loop. I mean I need to check YY result for loop 1, loop 2 and so on. Then, i need to compare the YY result for loop 1 with the YY result for loop 2. how can I do this?
  댓글 수: 1
Jan
Jan 2012년 4월 5일
Please use meaningful tags. "matlab code" is not helpful to identify the topic of your question.

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

답변 (2개)

Image Analyst
Image Analyst 2012년 4월 4일
What does "compare" mean to you? Do you mean like
difference = YY(n, count) - YY(1, count);
Is that what you mean?
  댓글 수: 2
Kugen Raj
Kugen Raj 2012년 4월 5일
i want check if the loop 2's YY result is better than loop 1's YY. That is why i'm comparing the YY result in each loop.
Image Analyst
Image Analyst 2012년 4월 5일
You can use Jan's code. You just have to code up what "better" means to you. We have no idea what "better" means.

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


Jan
Jan 2012년 4월 5일
This sounds like a straight task. Where is the problem?
YYold = inf; % arbitrary
for angle = 0:360
YY = rand; % your formula here
if angle > 0
% compare YY with YYold
end
YYold = YY;
end

카테고리

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

태그

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by