Borrar filtros
Borrar filtros

create periodic tasks set

3 visualizaciones (últimos 30 días)
joy
joy el 12 de En. de 2014
Editada: Amit el 12 de En. de 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?

Respuestas (1)

Amit
Amit el 12 de En. de 2014
Editada: Amit el 12 de En. de 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.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by