Clear Filters
Clear Filters

how to have an optional bus signal inside a subsystem?

5 views (last 30 days)
Hello,
I want to create a subsystem that I can reuse in different scenarios (maybe as subsystem reference, not really important).
I would like to pass the signal to this subsystem as a virtual bus.
Inside the subsystem I use the in bus element to get the signals I need from the bus.
Now, since I use this subsystem in different models/configurations there are signals that sometimes are present and sometimes are not present inside the virtual bus, like in the example image below: signal3 is not present inside the bus and so simulink throws the error:
Selected signal 'signal3' in the Bus Element Inport block 'untitledeee/Subsystem1/In Bus Element1' cannot be found in the input bus signal.
I would like to use a default value when I recognize that the input is missing. In matlab functions you can easily do this with optional arguments (link: arguments - defaultValue).
My question is: there is a way to replicate the optional arguments of matlab functions inside a subsystem/reference subsystem/model reference?
There is some suggested workaround?

Answers (1)

Ashutosh Thakur
Ashutosh Thakur on 17 Jun 2024
Hi Michele,
Simulink does not have a feature for handling optional arguments for the virtual bus in the way MATLAB code can. However, a strategy can be implemented to support this functionality. The following approach can be followed:
The combination of the above-mentioned blocks could help you in reusing your subsystem with optional signal values.
  1 Comment
Michele Oro
Michele Oro on 17 Jun 2024
Hi Ashutosh,
thank you for your suggestion. Unfortunately this solution at the core is manual solution while I am looking for something that could handle the situation with some automation.
But you are also right saying that simulink does not have this feature so I will probably have to accept some level of manual action.
Mic

Sign in to comment.

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!