- 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.
13 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
SOUMNATH PAUL
2023-11-15
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!