%% Create an observation specification object from a bus object
% This example shows how to use the function bus2RLSpec to create an observation specification object from a Simulink® bus object.
% Create a bus object.

obsBus = Simulink.Bus();

% Create three elements in the bus and specify their names.

obsBus.Elements(1) = Simulink.BusElement;
obsBus.Elements(1).Name = 'sin_theta';
obsBus.Elements(2) = Simulink.BusElement;
obsBus.Elements(2).Name = 'cos_theta';
obsBus.Elements(3) = Simulink.BusElement;
obsBus.Elements(3).Name = 'dtheta';

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

obsInfo = bus2RLSpec('obsBus');

% You can then use obsInfo, together with the corresponding Simulink model, to create a reinforcement learning environment. For an example, see Train DDPG Agent to Swing Up and Balance Pendulum with Bus Signal.
% Copyright 2019 The MathWorks, Inc.