Slow simulation because of matlab function block which interact with python code.

14 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

SOUMNATH PAUL
SOUMNATH PAUL el 15 de Nov. de 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:
  1. 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.
  2. 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
  3. 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
  4. You can consider using MATLAB Compiler to convert code into a standalone executable for faster execution.
  5. Experiment with different solver options and parameters in Simulink.
  6. Check if certain aspects of the simulation model can be simplified without sacrificing accuracy.
Hope it helps!
Regards,
Soumnath
  1 comentario
Mohammad
Mohammad el 15 de Nov. de 2023
Dear Soumnath,
Thank you for your time and consideration, I am gonoing to try those tips and let you know by the result!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by