Simulink assignment block writes garbage inside iterator subsystem.

16 visualizaciones (últimos 30 días)
Allan Yarbrough
Allan Yarbrough el 5 de Nov. de 2025
Editada: gowthaman muthuvel el 15 de Dic. de 2025 a las 10:26
I have an assignment block inside a complex model that I developed to run inside a time step. It should write a value to a 100-element array at the given index (zero-based). This is the expected behavior:
These are the assignment block parameters:
I then moved the model of which this was a part inside an iterated subsystem. Here is what I am getting:
The input U is being written to the array at the correct index, but the other elements of the array have been filled up with junk. (The "junk" in this case appears to be array values from MUCH earlier iterations before the array was re-initialized.) I note that this appears to only happen on this particular iteration; subsequent iterations overwrite the junk values at increasing indices as appropriate, but that is still leaving me with the value at the first index being incorrect.

Respuestas (1)

Leepakshi
Leepakshi el 17 de Nov. de 2025 a las 8:50
Hi Allan,
The array at the Y0 port should be constant if you want the Assignment block to reinitialize the output at every iteration. If the array is not constant, the block will accumulate changes, which may not be what you expect. Based on the understanding from your provided snippet.
If you share more about how <YArray> is connected, I might be able to provide you more specific answer.
Hope it helps!
  1 comentario
gowthaman muthuvel
gowthaman muthuvel hace alrededor de 14 horas
Editada: gowthaman muthuvel hace alrededor de 14 horas
Hello,
I'm facing the same issue, but In my case it's updating all the elements in the array with same value. But I am expecting array element to be updated with respect to the for iterator index value.
Could you guide me through to avoid this issue ?

Iniciar sesión para comentar.

Categorías

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

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by