How to create a variant sink condition depending on the input

6 views (last 30 days)
I would like for my Simulink signal to follow one route if it is negative, and another if it is positive. I am using a variant sink block in order to achieve this, but how can I make it dependent on the input rather than a predefined value in the workspace? I have tried using a To Workspace block, but this only creates the value after the simulation, meaning it can't be used in the variant sink. The input is coming from a step block that is manually changed depending on the desired simulation. Thanks in advance.

Accepted Answer

Gillian Rosen
Gillian Rosen on 14 Mar 2017
Hi Emily, 
I understand that you would like to find a variant sink block that changes condition depending on a signal input, instead of a workspace variable. 
One option that could work for you is to use a Manual Variant Sink block. You mentioned that you are manually changing the input to the Variant Sink depending on the desired simulation; with a Manual Variant Sink, you could manually change the path at this time as well. See the documentation for this block for more information: 
Another option for you could be to use a Switch block instead of a Variant Sink. With this method, you would connect your Step input to both paths, and at the end of the paths, place a Switch block that determines which path to follow. The control input for the Switch block can be some property of your Step input. See the documentation for examples and more information: 
  1 Comment
Bicheng Guo
Bicheng Guo on 13 Dec 2018
Hi, I have the same problem.
I have a s-function and it has 6 outputs, the next step is to determing is there a negtive in 6 outputs. If there is one negtive, the simulation should be stop. In this case, I choose a variant sink, one of the output connects to stop block and another connects to next s-functino to continue simulating. The thing is how can I use variant sink depending on its input?
I don`t choose a switch because it has only one output so i can`t connect it to two direction.
Thank you very much!

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!