MATLAB Answers

Simulink: Assign not using Y0 to initialize output in For loop

2 ビュー (過去 30 日間)
Cole Pratt
Cole Pratt 2019 年 11 月 6 日
Commented: Cole Pratt 2019 年 11 月 11 日
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?
2019-11-06_16-29-41.png

  0 件のコメント

サインイン to comment.

件の回答 (1)

Mark McBroom
Mark McBroom 2019 年 11 月 9 日
It would probaby be a lot easier to write and understand this if you use a MATLAB Function Block

  1 件のコメント

Cole Pratt
Cole Pratt 2019 年 11 月 11 日
I agree, it would. However, I am limited to only using a limited library of Simulink blocks for coding.

サインイン to comment.

サインイン してこの質問に回答します。

製品


リリース

R2018b

Translated by