Measure simulink step time

조회 수: 25 (최근 30일)
Marlo Wegener
Marlo Wegener 2017년 11월 21일
댓글: Francois Godin 2018년 1월 26일
Hello, I have a problem with a slow Simulink model and want to measure each time step in order to see how long time the execution takes. I use a fixed time step with a discrete solver and the step size is 0.01 seconds. Does anyone know how to measure how long each time step takes, i.e. how long real time for each sample? I tried to started digging and tested tic/toc and sim(modelname, 'Stoptime', 'simstoptime') in order to see how long the simulation takes with a fixed stop time but that only gives me the elapsed times for initialization, execution, termination and the total time. So this is not what I want to check, I want to know how long time each simulation step takes.
  댓글 수: 1
Francois Godin
Francois Godin 2018년 1월 25일
Hi Marlo, One way I found was to create a matlab function as follow:
function ExecTime = fcn(SimTime)
%#codegen
persistent t0;
coder.extrinsic('etime','clock')
if isempty (t0)
t0=clock;
ExecTime=0.0;
end
tnow = etime(clock,t0);
ExecTime = tnow;
I am using this with a variable step solver, so to avoid wasting too much CPU, I forced the block sampling with a rate transition. This would not work with code-generation as it uses extrinsic (matlab) functions.
Now, I am trying to extract other execution statistics such as step size, simulation order, ... to allow easier selection of the solver settings.
If anyone has an idea, let me know!

댓글을 달려면 로그인하십시오.

답변 (1개)

Nicolas Schmit
Nicolas Schmit 2018년 1월 26일
  댓글 수: 1
Francois Godin
Francois Godin 2018년 1월 26일
Bummer, introduced in 2017b. We are limited here at 2015a due to the Mathworks discontinued support to 32bit code generation.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by