How to calculate execution time of for loop inside the Math function block?
29 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Grégory SEABRA
2016-11-14
Hi,
have you tried using tic & toc functions?
5 个评论
Grégory SEABRA
2016-11-18
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
2016-11-18
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!