measure time of the algorithm in S-function builder in Simulink

3 次查看(过去 30 天)
I'm trying to create a sorting algorithm in simulink. You can't use matlab-function blocks because it's a recursive function, so I have to use the S-function builder. Now I want to know how long the algorithm takes for a different inputrange. This is my code:
clock_t begin = clock();
sort(x,0,999);
clock_t einde = clock();
*time = (einde - begin) / CLOCKS_PER_SEC;
The sorting function works fine. But the output for time is the first element in the sorted array. Which makes no sense!?
Anyone knows what might cause the problem? btw tic;toc; doesn't work in simulink, you have to write your own code.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by