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

조회 수: 4 (최근 30일)
Cole Pratt
Cole Pratt 2019년 11월 6일
댓글: Cole Pratt 2021년 2월 1일
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

답변 (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
  댓글 수: 3
Simon Geldermann
Simon Geldermann 2021년 2월 1일
Any solutions yet? I´m facing the same issue right now.
Cole Pratt
Cole Pratt 2021년 2월 1일
I got it working by seperating out the assignment. So I have two subsystems, the first to assign row "i" and the second to assign row "j". It doubles the number of iterations, but it is the only way I could get it to work.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by