diff options
author | ttt | 2018-07-09 16:54:44 +0530 |
---|---|---|
committer | ttt | 2018-07-09 16:54:44 +0530 |
commit | e5e316e1958e27696d7670e2492992d34ff38b68 (patch) | |
tree | 8dab5cc24e31921cfb3c44444d48cfbfd3ff76f8 /rarx.sci | |
parent | 681c88404f9f2861d228d0d0c3bd61b200ca1442 (diff) | |
download | FOSSEE-System-Identification-Toolbox-e5e316e1958e27696d7670e2492992d34ff38b68.tar.gz FOSSEE-System-Identification-Toolbox-e5e316e1958e27696d7670e2492992d34ff38b68.tar.bz2 FOSSEE-System-Identification-Toolbox-e5e316e1958e27696d7670e2492992d34ff38b68.zip |
added scilabs files
Diffstat (limited to 'rarx.sci')
-rw-r--r-- | rarx.sci | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/rarx.sci b/rarx.sci new file mode 100644 index 0000000..e2c291c --- /dev/null +++ b/rarx.sci @@ -0,0 +1,63 @@ +function varargout = rarx(varargin) + [lhs,rhs] = argn(0) +// + plantData = varargin(1) + orderData = varargin(2) + na = orderData(1);nb = orderData(2) + // arranging na ,nb,nk + if size(orderData,"*") == 2 then + nk = 1 + elseif size(orderData,'*') == 3 then + nk = orderData(3) + end + // storing the lambda value + if rhs == 3 then + lambda = varargin(3) + else + lambda = 0.95 + end + + nb1 = nb + nk - 1 + n = max(na, nb1) + // arranging the plant data + if typeof(plantData) == 'constant' then + Ts = 1;unitData = 'second' + elseif typeof(plantData) == 'iddata' then + Ts = plantData.Ts;unitData = plantData.TimeUnit + plantData = [plantData.OutputData plantData.InputData] + end + N = size(plantData,'r') + uIndex = nk:nb1 + yIndex = [] + if na <> 0 then + yIndex = 1:na + end + df = N - na - nb + Plast = 10^4 * (eye(na+nb,na + nb)) + theta = zeros(N + 1, na + nb) + yHat = plantData(:,1);yData = plantData(:,1) + tempData = zeros(N,na+nb) + for ii = 1:na + tempData(ii+1:ii+N,ii) = -plantData(:,1) + end + // arranging samples of u matrix + for ii = 1:nb + tempData(ii+nk:ii+N+nk-1,ii+na) = plantData(:,2) + end + //tempData = [zeros(1,na+nb);tempData] + tempData = tempData(1:N+1,:) + + for ii = 1:N + temp = tempData(ii,:) + yHat(ii) = temp*theta(ii,:)' + eps_i = yData(ii)-yHat(ii) + kappa_i = Plast * temp'/(lambda + temp * Plast * temp') + theta(ii+1,:) = ((theta(ii,:))' + eps_i * kappa_i)' + Plast = (eye(na + nb,na + nb) - kappa_i * (temp)) * Plast/lambda + + end + theta = theta(1:N,:) + yHat = yHat(1:N) + + varargout(1) = struct('theta',theta,'yHat',yHat) +endfunction |