Simulink: Assign not using Y0 to initialize output in For loop
Show older comments
I am attempting to swap elements in a vector in Simulink using the Assign block inside a For loop. For the first iteration of the loop, the code works properly and swaps the elements. On the next iterations, it appears that the Assign block is not using the Y0 input to initialize the output Y. Instead, it appears to only replace the U value and does not update the remainder of the vector with the new Y0 data.
How do I ensure that the output Y is reinitialized by the input vector Y0 before the element is replaced in every iteration of the for loop?

Answers (1)
Mark McBroom
on 9 Nov 2019
0 votes
It would probaby be a lot easier to write and understand this if you use a MATLAB Function Block
3 Comments
Cole Pratt
on 11 Nov 2019
Simon Geldermann
on 1 Feb 2021
Any solutions yet? I´m facing the same issue right now.
Cole Pratt
on 1 Feb 2021
Categories
Find more on Interactive Model Editing 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!