for in MATLAB Function block in Simulink

Facing trouble in implementing our algorithm in Simulink which contains for loop. For loop in MATLAB Function is not running properly.
We have MATLAB code which contains for loops. For loops ain't implemented in Simulink by us.
Please help us.
Waiting for reply.

 Respuesta aceptada

Andrey Kiselnikov
Andrey Kiselnikov el 22 de Jul. de 2019
Editada: Andrey Kiselnikov el 22 de Jul. de 2019

0 votos

There are two right ways to solve you problem:
  1. Refactor your code with replacing loops with matrix operations https://www.mathworks.com/matlabcentral/answers/369868-how-do-i-replace-my-for-loops-using-matrix-manipulation
  2. Build your algorithms with Stateflow

5 comentarios

Maitreyee Mordekar
Maitreyee Mordekar el 23 de Jul. de 2019
Hello Hemant,
It may be a little difficult to understand when you mention that for loop is not working correctly. Could you elaborate a little more? Also, just a note, you may not require for loops at certain times if you use vectorization:
As Andrey mentioned, you can consider using Stateflow!
Also, when you are using MATLAB Functions, ensure that your model is code generation capable.
I hope this helps!
-Maitreyee
HEMANT GHUGE
HEMANT GHUGE el 24 de Jul. de 2019
Thanks, I will go through it and let you know by tonight.
HEMANT GHUGE
HEMANT GHUGE el 24 de Jul. de 2019
Thanks Andrew Sir and Maitreyee Ma'am
Our model is good to go.
Maitreyee Mordekar
Maitreyee Mordekar el 24 de Jul. de 2019
Hello Hemant,
That's great to hear!
All the best,
Maitreyee
Andrey Kiselnikov
Andrey Kiselnikov el 24 de Jul. de 2019
If it was helpful you can mark answer as accepted ;)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink en Centro de ayuda y File Exchange.

Preguntada:

el 22 de Jul. de 2019

Comentada:

el 24 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by