%% Create an action specification object from a bus object
% This example shows how to call the function bus2RLSpec using name and value pairs to create an action specification object from a Simulink® bus object.
% Create a bus object.

actBus = Simulink.Bus();

% Create one element in the bus and specify the name.

actBus.Elements(1) = Simulink.BusElement;
actBus.Elements(1).Name = 'actuator';

% Create the observation specification objects using the Simulink bus object.

actInfo = bus2RLSpec('actBus','DiscreteElements',{'actuator',[-1 1]});

% This specifies that the 'actuator' bus element can carry two possible values, -1, and 1.
% You can then use actInfo, together with the corresponding Simulink model, to create a reinforcement learning environment. Specifically the function that creates the environment uses actInfo to determine the right bus output of the agent block.
% For an example, see Train DDPG Agent to Swing Up and Balance Pendulum with Bus Signal.
% Copyright 2019 The MathWorks, Inc.