how to have an optional bus signal inside a subsystem?

조회 수: 4 (최근 30일)
Michele Oro
Michele Oro 2024년 6월 6일
댓글: Michele Oro 2024년 6월 17일
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?

답변 (1개)

Ashutosh Thakur
Ashutosh Thakur 2024년 6월 17일
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
Michele Oro
Michele Oro 2024년 6월 17일
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

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

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by