How to use timer command?
이전 댓글 표시
How can I use timer to compare each row of the file for 0.2 sec and compare the azimuth column which is present in the comparing file. Doubt is: My covarage area is from 310 to 200 degree, for every 10 degree I need to compare whether azimuth is matching or not.
My Code:
load target.dat %contains 300 rows
for i=1:300
t=timer('TimerFcn',@myfun,'Period',0.2 ) ;
start(t);
delete(t);
end
function myfun()
for r=1:300
if target(r,2)>=310&&target(r,2)<=60
%eg:if the value in azimuth column is
%lies between 310 to 320 send that row
%of file which i am comparing (do this
%til reaching 60 degree)
%send 1 packet
elseif target(r,2)>60&&target(r,2)==90
%send 2 packet
else target(r,2)>90&&target(r,2) <=200
%send 1 packet
end
end
end
Please help me out in solving this. Thanks in advance.
댓글 수: 3
Walter Roberson
2019년 5월 19일
I reformatted your code for you; please check for correctness.
Note that
else target(r,2)=90&&target(r,2) <=200
means the same as
else
temp = 90 && (target(r,2) <=200);
target(r,2) = temp;
disp(target)
Walter Roberson
2019년 5월 19일
I see you changed your code. Note, however, that
else target(r,2)>90&&target(r,2) <=200
is equivalent to
else
temp = (target(r,2)>90) && (target(r,2) <=200);
disp(temp)
If you want a test then you need elseif -- and remember to always have an else in case none of the situations matched.
Chaithra D
2019년 5월 20일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Code Execution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!