- Focus on identifying and eliminating redundant operations, streamline loops, and consider vectorized computations. Additionally, you can leverage MATLAB's built-in functions and features that can enhance code efficiency for improved simulation performance.
- Explore parallel computing in MATLAB to distribute computations and enhance speed. You can find more information in the following link : https://in.mathworks.com/products/parallel-computing.html
- Use MATLAB's profiling tools to identify and address code bottlenecks. You can find more information in the following link : https://in.mathworks.com/help/matlab/matlab_prog/profiling-for-improving-performance.html
- You can consider using MATLAB Compiler to convert code into a standalone executable for faster execution.
- Experiment with different solver options and parameters in Simulink.
- Check if certain aspects of the simulation model can be simplified without sacrificing accuracy.
Slow simulation because of matlab function block which interact with python code.
8 views (last 30 days)
Show older comments
My simulation model has a Matlab function block which sends some data to a model in Python and receives the answer of the model to use it in simulation. My problem is my simulation is running so slow, however, when I increase the sample time of that Matlab function block it runs faster but at the cost of low accuracy! What is your suggestion to simulate without changing the sample time of that MATLAB function block?
0 Comments
Accepted Answer
SOUMNATH PAUL
on 15 Nov 2023
Hi Mohammed,
To my understanding your simulation runs slowly with the current setup, impacting efficiency and increasing the sample time of the MATLAB function block improves speed but sacrifices accuracy. Your concern is regarding the trade-off between simulation speed and accuracy when adjusting the sample time of the MATLAB function block. Here are few suggestions that can be followed:
Hope it helps!
Regards,
Soumnath
More Answers (0)
See Also
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!