Clear Filters
Clear Filters

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

3 views (last 30 days)
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.

Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!