How to find out whether a stateflow input variable receives an explicit value = 0 or is unconnected? How to treat optional inputs?

조회 수: 2 (최근 30일)
I have a state chart with several inputs that I save as a private Simulink library element for further use in different projects. One of these inputs (type=double or integer is suitable for my use-case) shall be optional - such that "base users" do not need to care about this, while advanced users can tailor this state chart's behaviour by using this optional input.
I want that the state chart's behaviour is as follows: If the input is "unconnected", the state chart shall behave as if this input is equal to -1 all the time.
What I understand is that the stateflow engine by default assigns a value = 0 to any unconnected "double type" input. So there is an "implicit initialization" of "zero" for input variables as it seems. Unlike for local or output variables, I am not allowed to set any init value for input variables (otherwise I would set init value = -1 in this example, so that if unconnected the variable carries the value -1 forever).
Right now all I could do is check the variabel for ==0. But if it is ==0, I do not know if it is because of a regularly connected input value==0, or because it is unconnected. That's bad for me.
Is there a way to find out if the variable is unconnected? Maybe there is a Matlab function that takes a stateflow input variable as function argument and returns true or false depending on whether the variable is (un)connected, like "isConnected(inputVariableName)" or "isConnected('inputVariableName')" or so...?
Any idea?

답변 (1개)

Muthukumar Ganesan
Muthukumar Ganesan 2022년 10월 26일
Hi,
It can be done by creating a mask, sample model is here.
Hope it helps.
Thanks

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by