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?

답변 (1개)

Mark McBroom
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
Bryan Callaway
Bryan Callaway 2019년 1월 11일
I can't find anything about a "Stateflow data editor". In the Stateflow "symbols" window, I can set data as input, output, etc., but I don't see anything about a bus.
Looking for similar solutions elsewhere, I did find an option in the model explorer to make the input or output "bus <data type>", but thus far no matter what I do with the data type field gives me the error:
"Invalid setting in 'Chart' for parameter 'Datatype'"
Could you provide more details around this solution? Thank you.
Mark McBroom
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 CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by