function rthosts_save

% Create a new real-time host environment collection object
rthosts_obj = simwb.rthosts
% Create a new real-time host environment object
rthostenv_obj = simwb.rthostenv
% Customize the real-time host environment by changing the name and IP
rthostenv_obj.Name = 'RedHawk1'
rthostenv_obj.RTHostNameorIP = '192.168.0.10'
% Add this custom real-time host environment to the collection
rthosts_obj.add(rthostenv_obj)
% Save the real-time host environment collection object to a MAT file
rthosts_obj.save
% Automatically reload the real-time host environment collection object
% from the MAT file
rthosts_obj = simwb.rthosts
rthosts_obj = 

  simwb handle

  Properties:
    NumHosts: 0



rthostenv_obj = 

  simwb.rthostenv handle
  Package: simwb

  Properties:
         Name: 'DefaultName'
    RTHostNameorIP: '127.0.0.1'



rthostenv_obj = 

  simwb.rthostenv handle
  Package: simwb

  Properties:
         Name: 'RedHawk1'
    RTHostNameorIP: '127.0.0.1'



rthostenv_obj = 

  simwb.rthostenv handle
  Package: simwb

  Properties:
         Name: 'RedHawk1'
    RTHostNameorIP: '192.168.0.10'



ans = 

  simwb handle

  Properties:
    NumHosts: 1



rthosts_obj = 

  simwb handle

  Properties:
    NumHosts: 1