Stateflow outputs a "mux" variable when I want a bus. How can I output a bus or reference specific elements of "mux"?
조회 수: 2 (최근 30일)
이전 댓글 표시
I am using Simulink to model a cyclical process. I am mainly interested in conditions at the end of each operating mode, so I want to store a list of variables each time a stateflow state switches. The system needs to tolerate storing several variables at the end of each state, so I cannot reasonably input and output each variable independently.
In my present solution, in addtion to its other functions, the stateflow block takes one input (a bus containing all the state information I want to save, "present_state") and produces one output for the end of each step in the cycle ("[X]_state"). Each stateflow "arrow" includes a statement that [X]_state=present_state. Thus, the output for [X]_state holds the variables of interest as they were the last time [X]_state ended.
This works well in every respect except that the outputs "[X]_state" turn out to be muxes rather than busses. I can use demux blocks to isolate the variables, but I don't have any reliable way of knowing which demux output corresponds with which bus input. While I can look at the outputs and guess which is which, this presents obvious risks for the robustness of the model as it is modified.
Is there some way I can tell stateflow that "present_state" is a bus, and have its bus characteristics carried through its internal logic so that I can use a bus selector to get specific variables? Are there other established solutions for this sort of problem?
댓글 수: 0
답변 (1개)
Mark McBroom
2019년 1월 11일
Have you tried creating a Simulink Bus and then in the Stateflow data editor setting the type of present_state to be the Simulink.Bus that you created?
댓글 수: 2
Mark McBroom
2019년 1월 12일
You have found the proper location to enter the bus data type. Do you have a Simulink.Bus defined in the MATLAB workspace? If so, then the syntax for specifying the data type to be a bus is ( assiming your bus is named "myBus") is:
Bus: myBus
Thanks.
Mark.
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!