%% Avoid Muxed Trigger Events with Binding
% Binding events gives control of a function-call subsystem to a single
% state in a chart. This control does not work when you allow other events
% to trigger the function-call subsystem through a mux. For example, this
% model defines two function-call events to trigger a function-call
% subsystem using a Mux block.

% Copyright 2018-2019 The MathWorks, Inc.

mdl = 'sf_bind_fcn_call_subsys_muxed_triggers';
load_system(mdl)
sim(mdl);
open_system(mdl)

%%
% In the chart, |E1| binds to state |A|, but |E2| does not. State |B| sends
% the triggering event |E2| in its entry action.

open_system('sf_bind_fcn_call_subsys_muxed_triggers/Chart')

%%
% When you simulate this model, the output does not reset when the
% transition from state |A| to state |B| occurs.

open_system('sf_bind_fcn_call_subsys_muxed_triggers/Scope')

%%
% Binding is not recommended when you provide multiple trigger events to a
% function-call subsystem through a mux. Muxed trigger events can interfere
% with event binding and cause undefined behavior.