필터 지우기
필터 지우기

Variant subystems with mixed discrete/continuous?

조회 수: 2 (최근 30일)
Jason
Jason 2012년 8월 10일
I am trying to use a variant subsystem to switch between a continuous block and a discrete block - a derivative block and a difference block, respectively. When the variant is set to the derivative block, the diagram will be used to run a simulation directly. When the variant is set to the difference block, the diagram will be used to generate code.
In principle, this should work, since only one variant is active at a time. When I generate code, I want the continuous variant to be left out completely, as it will be inactive. However, when I try to generate code, it complains that there are continuous states, so it can't (presumably because the derivative block is still there, even though it is inactive.) Is there some way that I can configure it to completely ignore non-active blocks, depending on how my variants are set?
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2012년 8월 11일
편집: Azzi Abdelmalek 2012년 8월 11일
what do you mean to generate code?
Jason
Jason 2012년 8월 16일
I am referring to the Simulink coder... ctrl+B

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

답변 (2개)

TAB
TAB 2012년 8월 13일
I think enabling Override variant conditions should work for you.
  댓글 수: 1
Jason
Jason 2012년 8월 16일
That option, as I understand it, merely removes the Variant Conditions from the picture, and allows you to specify a variant directly. My Variant Conditions are operating properly, and it shows the correct one as "true" in the variant subsystem parameters, so there's no reason to use this option.

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


Guy Rouleau
Guy Rouleau 2012년 8월 13일
I would be surprised if this is because of the derivative block. Usually, inactive variant should completely disappear.
- Ensure the option "Generate preprocessor conditional" is disabled. Otherwise both variants will be present... this is the only reason I know for 2 variants to be present.
- Use sample time colors or Simulink.BlockDiagram.getInitialState to identify which block has continuous state in your model.
  댓글 수: 1
Jason
Jason 2012년 8월 16일
I have the "generate preprocessor conditionals" disabled, but it appears that when code is generated is still cares about the inactive variant. I don't know why.
Can you elaborate on the sample time colors? I don't understand what you are saying here.

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

카테고리

Help CenterFile Exchange에서 Component-Based Modeling에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by