How to calculate execution time of for loop inside the Math function block?
조회 수: 30 (최근 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!