create periodic tasks set
4 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!