%% Programmatically Convert Subsystem to Referenced Model
% Convert the |Bus Counter| subsystem to a referenced model named
% |bus_counter_ref_model|.
%
open_system('sldemo_mdlref_conversion');
Simulink.SubSystem.convertToModelReference(...
   'sldemo_mdlref_conversion/Bus Counter', ...
   'bus_counter_ref_model', ...
   'AutoFix',true,...
   'ReplaceSubsystem',true,...
   'CheckSimulationResults',true);

% Copyright 2021 The MathWorks, Inc.