how to solve this problem?
When I run the code I get this error
clc;
% System parameters definition
m = 10;
A = [0 1; 0 0];
B = [0; 1/m];
C = [1 0; 0 1];
D = 0;
% State-space model creation
sys = ss(A, B, C, D);
% Number of experiments
N = 1000;
U = cell(N,1);
Y = cell(N,1);
rng(0);
%% Dataset generation for identification
for i = 1:N
% Generating random input sequence (force)
t = linspace(0, 1, 11)’;
u = 0.5 * randn(size(t));
% Random initial conditions for velocity and position
x0 = [0.5 * randn(1, 1); 0.5 * randn(1, 1)];
% System simulation
x = lsim(sys, u, t, x0);
% Saving input sequences and state measurements
U{i} = timetable(seconds(t), u);
Y{i} = timetable(seconds(t), x(:,1), x(:,2));
end
%% Generate Data Set for Validation
% Use random initial state and input sequence
t = linspace(0,10,101)’;
u = 0.5*randn(size(t));
x0 = [0.5*randn(1,1);0.5*randn(1,1)];
% Obtain state measurements over t
x = lsim(sys,u,t,x0);
% Append the validation experiment (also a timetable) as the last entry in the data set
U{end+1} = timetable(seconds(t), u);
Y{end+1} = timetable(seconds(t), x(:,1), x(:,2));
%% Creation and initialization of the state-space model
sys = idNeuralStateSpace(2, NumInputs=1); % Valid if nx=ny where nx is the number of states and ny is the number of outputs
sys.StateName = {‘Position’, ‘Velocity’}; % State variable names declaration
sys.InputName = ‘Force’; % Input name declaration (1 in this case)
sys.InputUnit = ‘N’;
sys.OutputName = {‘Position’, ‘Velocity’}; % Output names addition
sys.StateUnit = {‘m’, ‘m/s’};
sys.OutputUnit = sys.StateUnit;
sys.Notes = "Prediction Model using Neural Network";
%% Inner layers declaration for the state network
% State network
sys.StateNetwork = createMLPNetwork(sys, ‘state’, …
‘LayerSizes’, 128, …
‘Activations’, "tanh", …
‘WeightsInitializer’, "glorot", …
‘BiasInitializer’, "zeros");
%% Training options declaration for the state network
opt = nssTrainingOptions(‘adam’);
opt.MaxEpochs = 400;
opt.MiniBatchSize = N;
opt.LearnRate = 0.005;
%% Testing
resultTrain = nlssest(U, Y, sys, opt, ‘UseLastExperimentForValidation’, true);
where am I wrong?When I run the code I get this error
clc;
% System parameters definition
m = 10;
A = [0 1; 0 0];
B = [0; 1/m];
C = [1 0; 0 1];
D = 0;
% State-space model creation
sys = ss(A, B, C, D);
% Number of experiments
N = 1000;
U = cell(N,1);
Y = cell(N,1);
rng(0);
%% Dataset generation for identification
for i = 1:N
% Generating random input sequence (force)
t = linspace(0, 1, 11)’;
u = 0.5 * randn(size(t));
% Random initial conditions for velocity and position
x0 = [0.5 * randn(1, 1); 0.5 * randn(1, 1)];
% System simulation
x = lsim(sys, u, t, x0);
% Saving input sequences and state measurements
U{i} = timetable(seconds(t), u);
Y{i} = timetable(seconds(t), x(:,1), x(:,2));
end
%% Generate Data Set for Validation
% Use random initial state and input sequence
t = linspace(0,10,101)’;
u = 0.5*randn(size(t));
x0 = [0.5*randn(1,1);0.5*randn(1,1)];
% Obtain state measurements over t
x = lsim(sys,u,t,x0);
% Append the validation experiment (also a timetable) as the last entry in the data set
U{end+1} = timetable(seconds(t), u);
Y{end+1} = timetable(seconds(t), x(:,1), x(:,2));
%% Creation and initialization of the state-space model
sys = idNeuralStateSpace(2, NumInputs=1); % Valid if nx=ny where nx is the number of states and ny is the number of outputs
sys.StateName = {‘Position’, ‘Velocity’}; % State variable names declaration
sys.InputName = ‘Force’; % Input name declaration (1 in this case)
sys.InputUnit = ‘N’;
sys.OutputName = {‘Position’, ‘Velocity’}; % Output names addition
sys.StateUnit = {‘m’, ‘m/s’};
sys.OutputUnit = sys.StateUnit;
sys.Notes = "Prediction Model using Neural Network";
%% Inner layers declaration for the state network
% State network
sys.StateNetwork = createMLPNetwork(sys, ‘state’, …
‘LayerSizes’, 128, …
‘Activations’, "tanh", …
‘WeightsInitializer’, "glorot", …
‘BiasInitializer’, "zeros");
%% Training options declaration for the state network
opt = nssTrainingOptions(‘adam’);
opt.MaxEpochs = 400;
opt.MiniBatchSize = N;
opt.LearnRate = 0.005;
%% Testing
resultTrain = nlssest(U, Y, sys, opt, ‘UseLastExperimentForValidation’, true);
where am I wrong? When I run the code I get this error
clc;
% System parameters definition
m = 10;
A = [0 1; 0 0];
B = [0; 1/m];
C = [1 0; 0 1];
D = 0;
% State-space model creation
sys = ss(A, B, C, D);
% Number of experiments
N = 1000;
U = cell(N,1);
Y = cell(N,1);
rng(0);
%% Dataset generation for identification
for i = 1:N
% Generating random input sequence (force)
t = linspace(0, 1, 11)’;
u = 0.5 * randn(size(t));
% Random initial conditions for velocity and position
x0 = [0.5 * randn(1, 1); 0.5 * randn(1, 1)];
% System simulation
x = lsim(sys, u, t, x0);
% Saving input sequences and state measurements
U{i} = timetable(seconds(t), u);
Y{i} = timetable(seconds(t), x(:,1), x(:,2));
end
%% Generate Data Set for Validation
% Use random initial state and input sequence
t = linspace(0,10,101)’;
u = 0.5*randn(size(t));
x0 = [0.5*randn(1,1);0.5*randn(1,1)];
% Obtain state measurements over t
x = lsim(sys,u,t,x0);
% Append the validation experiment (also a timetable) as the last entry in the data set
U{end+1} = timetable(seconds(t), u);
Y{end+1} = timetable(seconds(t), x(:,1), x(:,2));
%% Creation and initialization of the state-space model
sys = idNeuralStateSpace(2, NumInputs=1); % Valid if nx=ny where nx is the number of states and ny is the number of outputs
sys.StateName = {‘Position’, ‘Velocity’}; % State variable names declaration
sys.InputName = ‘Force’; % Input name declaration (1 in this case)
sys.InputUnit = ‘N’;
sys.OutputName = {‘Position’, ‘Velocity’}; % Output names addition
sys.StateUnit = {‘m’, ‘m/s’};
sys.OutputUnit = sys.StateUnit;
sys.Notes = "Prediction Model using Neural Network";
%% Inner layers declaration for the state network
% State network
sys.StateNetwork = createMLPNetwork(sys, ‘state’, …
‘LayerSizes’, 128, …
‘Activations’, "tanh", …
‘WeightsInitializer’, "glorot", …
‘BiasInitializer’, "zeros");
%% Training options declaration for the state network
opt = nssTrainingOptions(‘adam’);
opt.MaxEpochs = 400;
opt.MiniBatchSize = N;
opt.LearnRate = 0.005;
%% Testing
resultTrain = nlssest(U, Y, sys, opt, ‘UseLastExperimentForValidation’, true);
where am I wrong? nlssest, matlab code MATLAB Answers — New Questions