MATLAB: Low-Level Nonlinearity Evaluation Using Wavenet (SISO System)

narxnlarxwavenet

Hello!
I'm trying to do a low-level nonlinearity evaluation to a NARX model based on wavenet estimator. This manipulation is based on http://www.mathworks.com/help/toolbox/ident/ug/bq5o_xw-1.html#br7139m.
As we see below, only a subset of regressors (in case, [y1(t-2), u1(t-1)]) are input to nonlinear function
M5 = NLARX(estData, [2 2 1], wavenet('Num',5), 'nlr', [2 3],'Focus', 'prediction', 'Display', 'on')
NL = M5.Nonlinearity; NL.Parameters; r = NL.Parameters.RegressorMean; Q=NL.Parameters.NonLinearSubspace; P=NL.Parameters.LinearSubspace; L=NL.Parameters.LinearCoef; as=NL.Parameters.ScalingCoef; aw=NL.Parameters.WaveletCoef; bs=NL.Parameters.ScalingDilation; bw=NL.Parameters.WaveletDilation; cs=NL.Parameters.ScalingTranslation; cw=NL.Parameters.WaveletTranslation; d = NL.Parameters.OutputOffset;
Where am I wrong?
x = [estData.y(1),0,estData.u(1),0]; %regressor(y(t-1) y(t-2) u(t-1) u(t-2)) values that are input in the linear function at t=1.
xnln = [0,0,estData.u(1),0]; %regressor(y(t-2) u(t-1)) values that are input in the nonlinear function at t=1.
% Compute the linear portion of the response (plus offset):
yLinear = (x-r)*P*L+d;
% Compute the nonlinear portion of the response:
f = @(z)(exp(-0.5*z'*z));%scale function (father wavelet)
yNonlinear1 = 0;
for k = 1:length(cs)
finputS = (bs*(xnln-r))*Q – cs(k);
yNonlinear1 = yNonlinear1 + as*f(finputS);
end
g = @(zz)((length(zz)-zz'*zz))*(exp(-0.5*zz'*zz));%wavelet function ("Mexican hat" mother wavelet)
yNonlinear2 = 0;
for k = 1:length(aw)
finputW = (bw(k,:)*(xnln-r))*Q – cw(k);
yNonlinear2 = yNonlinear2 +aw(k)*g(finputW);
end
% Total response y = F(x) = yLinear + yNonlinear1 + yNonlinear2
y = yNonlinear1 + yNonlinear2 + yLinear
In this case, i got the following response: y =
0.1126 0.1127
0.1127 0.1128
I would have to obtain a real number, is not it? the results obtained from the above steps must be equal to evaluate(NL,x)
Thanks

Best Answer

In the f(0 and g() formulas you need an inner product.
In your formula for f(), replace z'*z by z*z'. In the formula for g(), replace zz'*zz by zz*zz'.
This was a typo in the doc some time ago, now fixed. The online documentation shows the correct formula.
Rajiv