Borrar filtros
Borrar filtros

How to calculate execution time of for loop inside the Math function block?

30 visualizaciones (últimos 30 días)
for k = 1:16
state=[ 1 0 1 0 1 0 1 0 ;
1 0 1 0 1 0 0 1 ;
1 0 1 0 0 1 1 0 ;
1 0 1 0 0 1 0 1 ;
1 0 0 1 1 0 1 0 ;
1 0 0 1 1 0 0 1 ;
1 0 0 1 0 1 1 0 ;
1 0 0 1 0 1 0 1 ;
0 1 1 0 1 0 1 0 ;
0 1 1 0 1 0 0 1 ;
0 1 1 0 0 1 1 0 ;
0 1 1 0 0 1 0 1 ;
0 1 0 1 1 0 1 0 ;
0 1 0 1 1 0 0 1 ;
0 1 0 1 0 1 1 0 ;
0 1 0 1 0 1 0 1 ];
Si1=state(k,1);
Si3=state(k,3);
Si5=state(k,5);
Si7=state(k,7);
.............
.................
g = abs(irefa-io_p_a) + abs(irefb-io_p_b) + abs(irefc-io_p_c)+lambda_sw*abs(Si7-Si7_prev);
if (g<g_opt)
.............
..........
end
end

Respuestas (1)

Grégory SEABRA
Grégory SEABRA el 14 de Nov. de 2016
Hi,
have you tried using tic & toc functions?
  5 comentarios
Grégory SEABRA
Grégory SEABRA el 18 de Nov. de 2016
If you use the tic toc fonctions in a math function block, you must output the toc result out of this block, otherwise you won't be able to visualize it as you put ";" after them..
Furthermore, you might not be able to simulate in accelerator or rapid accelerator mode because it generate code from this function...
Walter Roberson
Walter Roberson el 18 de Nov. de 2016
Are you using any accelerator mode other than "normal"? Or are you trying to deploy to a hardware device, and if so then which one?
We need this information in order to be able to figure out the appropriate replacement timing mechanism for your situation. We could tell you to just toss in the coder.extrinsic('tic') and coder.extrinsic('toc') like in the error message, but that will only work for the "normal" and "accellerator" mode and not for rapid accelerator mode and not for deployment to hardware.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by