Azzera filtri
Azzera filtri

create periodic tasks set

3 visualizzazioni (ultimi 30 giorni)
joy
joy il 12 Gen 2014
Modificato: Amit il 12 Gen 2014
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?

Risposte (1)

Amit
Amit il 12 Gen 2014
Modificato: Amit il 12 Gen 2014
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.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by