Simulink Switch Block Input Calculation

조회 수: 3 (최근 30일)
Alexis
Alexis 2023년 4월 20일
댓글: Paul 2023년 4월 23일
I am trying to do the Model as efficient as possible, since I then have to generate C++ code and run it on a different platform, thus the following Question is regarding the Switch Block in Simulink and the calculation of its input.
Lets say I have a boolean which when set to TRUE does a big calculation but then when it is set to FALSE does not calculate anything. When using the Switch Block, does is nevertheless do the big calculation even though it is set to FALSE?
From my knowledge it would not do the calculation if I were using a if block, but I would prefer using the switch, since it is much smaller and easier to understand.

채택된 답변

Mark McBroom
Mark McBroom 2023년 4월 22일
Embedded coder attempts to pull upstream calculations inside the if-then C++ code generated for a switch block. However, to ensure code only gets executed when a particular condition is true, use IF-Then-Elese subsystems rather than switch block in the Simulink model.
Thanks.
Mark.
  댓글 수: 3
Mark McBroom
Mark McBroom 2023년 4월 23일
I would expect upstream content to be pulled inside the if-then until a signal is branched or an atomic subsystem boundary is encountered.
Thanks.
Mark.
Paul
Paul 2023년 4월 23일
Does upstream signal logging come into play? Seems like it must for running the model in Simulink, but I don't know if signal logging means anything when generating code to run on a different platform, as is the intent of the OP.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by