本文整理汇总了C#中ILArray._Scalar方法的典型用法代码示例。如果您正苦于以下问题:C# ILArray._Scalar方法的具体用法?C# ILArray._Scalar怎么用?C# ILArray._Scalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILArray
的用法示例。
在下文中一共展示了ILArray._Scalar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RLSMARX1
//.........这里部分代码省略.........
else
{
sigma = sigma0;
}
if (all(all(theta0 == 0))) // No sigma0 specifyed
{
theta = zeros(n + m, n);
}
else
{
theta = theta0;
}
// Start with a offline estimate if initial parameters are not specifyed
if (all(__[ theta0, ';', sigma0 ] == 0))
{
NIni = max(n + 1, ceil_(N * IniNumSampFrac));
XX = __[ X[_(1, ':', NIni - 1), _(':')], U[_(1, ':', NIni - 1), _(':')] ];
YY = X[_(_c_(1, NIni - 1) + 1), _(':')];
R = _m(XX.T, '*', XX);
theta = _m(_m(inv(R), '*', (XX.T)), '*', YY);
Epsilon = YY - _m(XX, '*', theta);
sigma = _m(Epsilon.T, '*', Epsilon) / NIni;
xh = _m(XX[_(end), _(':')], '*', theta);
}
else
{
NIni = 1;
xh = X[_(1), _(':')];
R = 1e6 * eye(n);
}
lambda = lambda0;
Res = __[ NIni, (theta[_(':')]).T, (sigma[_(':')]).T, xh, lambda ];
AByTime = zeros(n, n, N - NIni + 1);
AByTime[_(':'), _(':'), _(1)] = (theta[_(1, ':', n), _(1, ':', n)]).T;
BByTime = zeros(n, m, N - NIni + 1);
BByTime[_(':'), _(':'), _(1)] = (theta[_(n + 1, ':', n + m), _(1, ':', n)]).T;
SigmaByTime = zeros(n, n, N - NIni + 1);
SigmaByTime[_(':'), _(':'), _(1)] = sigma;
// Recursion
// Model x(n+1)= A*x(n)+B*u(n)+e(n) <=>
// x(n+1)'= [x(n)' u(n)']*[A'; B']+e(n)
for (i = NIni + 1; i <= N; i++)
{
phi = (__[ X[_(i - 1), _(':')], U[_(i - 1), _(':')] ]).T; // phi(i)
R = (lambda._Scalar()) * R + _m(phi, '*', (phi.T)); // R(i)
xh = _m((phi.T), '*', theta); // xh(i)
epsilon = X[_(i), _(':')] - xh; // epsilon(i)
theta = theta + _m(_s(R, '\\', phi), '*', epsilon); // theta(i)
sigma = _m(lambda, '*', sigma) + _m(_m((1 - lambda), '*', (epsilon.T)), '*', epsilon);
Res = __[ Res, ';', __[ i, theta[_(':')].T, sigma[_(':')].T, xh, lambda ] ];
lambda = lambdaL * lambda + (1 - lambdaL) * lambdaInf;
AByTime[_(':'), _(':'), _(i - NIni + 1)] = (theta[_(1, ':', n), _(1, ':', n)]).T; // Index start at 2
BByTime[_(':'), _(':'), _(i - NIni + 1)] = (theta[_(n + 1, ':', n + m), _(1, ':', n)]).T;
SigmaByTime[_(':'), _(':'), _(i - NIni + 1)] = sigma;
}
// Res is organised like
// i theta(:)' sigma(:)' xh lambda with the dimensions
// 1 (n+m)*n n^2 n 1
Time = _int(Res[_(':'), _(1)]);
Theta = Res[_(':'), _(1 + 1, ':', 1 + (n + m) * n)];
Sigma = Res[_(':'), _(1 + 1 + (n + m) * n, ':', 1 + (n + m) * n + _p_(n, 2))];
Xh = Res[_(':'), _(1 + 1 + (n + m) * n + _p_(n, 2), ':', 1 + (n + m) * n + _p_(n, 2) + n)];
Lambda = Res[_(':'), _(1 + 1 + (n + m) * n + _p_(n, 2) + n, ':', end)];
// Do informative plotting and output
//if (Plot)
//{
// figure;
// plot([U X]);
// title('Input and measurements');
// figure;
// plot(Time,reshape(AByTime,n*n,N-NIni+1)');
// title('A parameters');
// figure;
// plot(Time,reshape(BByTime,n*m,N-NIni+1)');
// title('B parameters');
// figure;
// plot(Time,reshape(SigmaByTime,n*n,N-NIni+1)');
// title('Sigma parameters');
// figure;
// plot(Time,Lambda);
// title('Lambda');
// Epsilon= X(Time,:)-Xh;
// Epsilon= Epsilon(100:end,:);
// figure;
// XCorrtkAll(Epsilon);
// figure;
// normplot(Epsilon);
// gridtk('on',figures);
// Lab= ['Final parameters A n*n B n*m Sigma n*n'];
// RowLab= {''};
// ColLab= {''};
// Res= [AByTime(:,:,end) BByTime(:,:,end) SigmaByTime(:,:,end)];
// printmattk(Res,Lab);
//}
}