필터 지우기
필터 지우기

create periodic tasks set

조회 수: 3 (최근 30일)
joy
joy 2014년 1월 12일
편집: Amit 2014년 1월 12일
Hi,
I want to create a set of periodic task sets with different period and execution time.I need to generate a code template where if i give a period and execution time then the tasks set would be created..
tasks set would be consists of few nested for loops...i think
for(;;)
{
for(;;)
{
}
}
this are execution time
then
sleep()
so, is it the right approach to do so?...I think execution time would be the time taken to execute for loops and period will be execution time of for loops+sleep time.
any suggestions?

답변 (1개)

Amit
Amit 2014년 1월 12일
편집: Amit 2014년 1월 12일
Lets say you have execution time and period in vector A and B, respectively. Then you might do something like this:
for i = 1:numel(A)
t_in = cputime;
while((cputime - t_in) <= A(i))
_Do Your Thing_
end
pause(B(i)-A(i));
end
Just want to add that calculating while condition will take some time as well, thus the do your thing will be executed for slightly lesser time than actual execution time.

카테고리

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