Simulink: Matlab Fcn Block - Horrendously Slow!
4 views (last 30 days)
Show older comments
Your help is much appreciated. I have a Matlab file that sets up some variables (1x1 doubles, a couple of 4x1 arrays) including a large simin array of size 2x20001 before running a simulink simulation.
This simulation primaily includes a matlab function block with 13 inputs, 4 outputs. of these 13 inputs, 9 are constants defined in the matlab workspace, 2 relate to the simin array and 2 are iterated results from ODE solvers (for motion).
The function block contains 66 lines of well spaced out code, all very simple maths equations. The only exception is a call of a matlab function, one i have previously used with no problems in terms of running speed.
My simulation takes a very long time to run, in the region of 4 minutes for '50 seconds' of simulation time. In the past I have been able to generate '200' seconds of simulation time within less than a minute.
I have used the simulink profiler report to diagnose the matlab function block as the cause; it uses 90% of the time and calls that run during the simulation.
I have tried reducing the step size of my solvers, but this results in INF errors almost imediately, they run at a typical value of 1exp-5.
Your thoughts please on what I can do to address this problem, or where matlab/simulink can help my diagnose it further!
0 Comments
Answers (1)
Kaustubha Govind
on 19 Mar 2012
Could you try running the code directly in MATLAB in a loop to imitate the behavior of the MATLAB Function block in a simulink model? Does it run slowly too? This could help you determine whether it is the block causing the issue or if it's something in the code itself that is slowing down execution.
0 Comments
See Also
Categories
Find more on Manual Performance Optimization 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!