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?
0 个评论
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!