I want to add elements to matrix.
I want to add the calculated value to the end. In the code below, I would like to add the calculated value of R to RR.
I tried R = ; RR (end + 1) = R ;, but only one value was added.
I want to add all the R calculated in one simulation to the RR.(R is one value.)
function [NextObservation, Reward, IsDone, LoggedSignals] = myStepfunction(Action,LoggedSignals,SimplePendulum)
statePre(1) = SimplePendulum.Theta;
statePre(2) = SimplePendulum.AngularVelocity;
state(1) = SimplePendulum.Theta;
state(2) = SimplePendulum.AngularVelocity;
X_state_Position = sin(state(1));
Y_state_Position = -cos(state(1));
Ball_Distance = X_state_Position + (-state(2))* sqrt(2*abs(Y_state_Position)/9.8);
R = -abs(Ball_Distance -Ball_Target);
if (state(2) > 0) || (SimplePendulum.Y_Position < 0)
[InitialObservation, LoggedSignal] = myResetFunction(SimplePendulum);
LoggedSignal.State = [-pi/2 ; 0];
InitialObservation = LoggedSignal.State;
state = InitialObservation;
SimplePendulum.AngularVelocity = 0;
LoggedSignals.State = state;
NextObservation = LoggedSignals.State;