Issue with Sigmoidnet input function

1 view (last 30 days)
Sharmila Biswas
Sharmila Biswas on 16 Sep 2019
This is the code I am using for generating the predicted output ('yo' as mentioned in the code) from given input ('u' as mentioned in the code) and output ('y' as mentioned in the code). Though I am getting 100% data fitting during training, the trained parametric sigmoidnet model ('sys' as mentioned in the code) is predicting completely different output from the same data used for training. Can soemone please help to find out bugs in the code if there are any? Furthermore, is there any alternative method to generate predicted output from given input using sigmoidnet function?
The code is written below:
data=iddata(y,u);
sys = nlarx(data,[2 2 1],sigmoidnet('NumberOfUnits',3))
% u is the input to the model
% y is true output of the model
% x is the regressor value vector, na=nb=2 and nk=1, so number of
% regressor=4
% yo is the predicted output
P = sys.Nonlinearity.Parameters.LinearSubspace;
r = sys.Nonlinearity.Parameters.RegressorMean;
L = sys.Nonlinearity.Parameters.LinearCoef;
Q = sys.Nonlinearity.Parameters.LinearSubspace;
b = sys.Nonlinearity.Parameters.Dilation;
c = sys.Nonlinearity.Parameters.Translation;
a = sys.Nonlinearity.Parameters.OutputCoef;
d = sys.Nonlinearity.Parameters.OutputOffset;
yo = [];
for i=1:size(u,1)
x= zeros(1,4);
if i==1
x(1)=0;
x(2)=0;
x(3)=0;
x(4)=0;
elseif i==2
x(1)=data.y(i-1);
x(2)=0;
x(3)=data.u(i-1);
x(4)=0;
else
x(1)=data.y(i-1);
x(2)=data.y(i-2);
x(3)=data.u(i-1);
x(4)=data.u(i-2);
end
y_element = (x-r)*P*L + a(1)*1/(exp(-((x-r)*Q*b(:,1) + c(1)) +1)) ...
+ a(2)*1/(exp(-((x-r)*Q*b(:,2) + c(2)) +1)) ...
+ a(3)*1/(exp(-((x-r)*Q*b(:,3) + c(3)) +1)) ...
+ d;
disp(y_element)
yo = [yo; y_element];
end
% Final predicted output for display
out_predict = yo;

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!