필터 지우기
필터 지우기

Performance Problem in Simulink (why is it slower than matlab?)

조회 수: 6 (최근 30일)
Akbar
Akbar 2018년 4월 10일
편집: Akbar 2018년 4월 12일
I have compared Solutions to the same ODE in matlab and simulink. Simulink took 7.6 sec. while ode15s in matlab took 1.4 sec. to solve. What is the reason for this time difference? FYI: I used the same number of time steps in both cases. And simulink model was run from matlab, using 'sim' function.
  댓글 수: 1
Akbar
Akbar 2018년 4월 12일
Matlab code:
for i = 1:100
[t{ind},X{ind}] = ode15s(func,0:.1:10,X0);
end
Simulink code:
for i = 1:100
simOut = sim(model_file,'SimulationMode','normal');
outputs = simOut.get('yout');
outI = outputs.get('X');
t{ind} = outI.Values.Time;
X{ind} = outI.Values.Data;
end

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

답변 (1개)

Steven Lord
Steven Lord 2018년 4월 10일
Which solver did you use when you simulated your system? Did you leave the selection up to Simulink?
The ode15s solver in MATLAB is a stiff solver while ode45 is not. So if your simulation used ode45, to compare apples and apples you'd want to compare that with solving the system in MATLAB using ode45 (or switch both to use a stiff solver.)
  댓글 수: 1
Akbar
Akbar 2018년 4월 12일
편집: Akbar 2018년 4월 12일
In simulink I used: "VariableStepAuto". I have just tried ode15s on both (with the same stepsize: 0.1) and still got a significant difference in time. Apart from that, simulink and ode45 have failed to solve the System correctly, it deviated from the true solution.
ode15s: 0.8488
ode45: 0.088538
simulink (normal): 13.2582

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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by