| Contents | Index |
At compile time, informative diagnostic messages appear to help you:
Design Mealy and Moore charts from scratch
Redesign legacy Classic charts to conform to Mealy and Moore semantics
Redesign charts to convert between Mealy and Moore types
For example, recall the Mealy vending machine chart described in Example: Mealy Vending Machine.

If you change the chart type to Moore and rebuild, you get the following diagnostic message:
Stateflow Moore chart cannot have condition or transition actions.
This indicates that you cannot define actions on transitions. Without actions, you cannot compute outputs on transitions in Moore charts (see Do Not Use Actions on Transitions). According to Moore semantics, you must instead compute outputs in state actions (see Design Rules for Moore Charts).
In the Mealy chart, each condition action computes output (whether or not soda is released) based on input (the coin received). Each state represents one of the three possible coin inputs: nickel, dime, or no coin. The Mealy chart computes the output as it transitions to the next state. When you move this logic out of transitions and into state actions in the Moore chart, you need more states. The reason is that in the Moore chart, each state must represent not only coins received, but also the soda release condition. The Moore chart must compute output according to the active state before considering input. As a result, there will be a delay in releasing soda, even if the machine receives enough money to cover the cost.
The equivalent vending machine, designed as a Moore chart, is as follows.

The semantics of the two charts differ as follows:
| Mealy Vending Machine | Moore Vending Machine |
|---|---|
| Uses 3 states | Uses 5 states |
| Computes outputs in condition actions | Computes outputs in state actions |
| Updates output based on input | Updates output before evaluating input, requiring an extra time step to produce the soda |
For this vending machine, Mealy is a better modeling paradigm because there is no delay in releasing soda once sufficient coins are received. By contrast, the Moore vending machine requires an extra time step to pass before producing soda. Since the Moore vending machine accepts a nickel, a dime, or no coin in a given time step, it is possible that the soda will be produced in a time step in which a coin is accepted toward the next purchase. In this situation, the delivery of a soda may appear to be in response to this coin, but actually occurs because the vending machine received the purchase price in previous time steps.
![]() | Effects of Changing the Chart Type | Techniques for Streamlining Chart Design | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |