summaryrefslogtreecommitdiff
path: root/compareBJ.sci
diff options
context:
space:
mode:
authorttt2018-07-09 16:54:44 +0530
committerttt2018-07-09 16:54:44 +0530
commite5e316e1958e27696d7670e2492992d34ff38b68 (patch)
tree8dab5cc24e31921cfb3c44444d48cfbfd3ff76f8 /compareBJ.sci
parent681c88404f9f2861d228d0d0c3bd61b200ca1442 (diff)
downloadFOSSEE-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 'compareBJ.sci')
-rwxr-xr-xcompareBJ.sci56
1 files changed, 56 insertions, 0 deletions
diff --git a/compareBJ.sci b/compareBJ.sci
new file mode 100755
index 0000000..06d2fb8
--- /dev/null
+++ b/compareBJ.sci
@@ -0,0 +1,56 @@
+function varargout = compareBJ(varargin)
+ //varargin(1) -> idpoly data about oe
+ //varargin(2) -> [y u] matrix of "nx2" dimension
+ //disp('compareBj')
+ bjData = varargin(1)
+ //disp(typeof(bjData))
+ plantData = varargin(2)
+ //disp(typeof(plantData))
+ yData = plantData(:,1)
+ uData = plantData(:,2)
+ uData = [0;uData]
+ //storing the data in A,B,C,D,F matrix
+ // B(z) C(z)
+ // y(n)=---------- u(n)+ ----------- e(n)
+ // A(z)F(z) A(z)D(z)
+ polyA = poly(bjData.a,'x','coeff')
+ polyB = poly(bjData.b,'x','coeff')
+ polyC = poly(bjData.c,'x','coeff')
+ polyD = poly(bjData.d,'x','coeff')
+ polyF = poly(bjData.f,'x','coeff')
+ adf = polyA*polyD*polyF
+ bd = polyB*polyD
+ cf = polyC*polyF
+ delay = max(size(coeff(adf),'*'),size(coeff(bd),'*'),size(coeff(cf),'*'))
+ yHat = [0]
+ bdCoeff = coeff(bd)
+ adfCoeff = coeff(adf)
+ adfCoeff = -adfCoeff(2:length(adfCoeff))
+ for ii = 1:length(uData)
+ uSum = 0;ySum = 0;
+ for jj = 1:length(bdCoeff)
+ if ii-jj <= 0 then
+ uSum = uSum + 0
+ else
+ uSum = uSum + uData(ii-jj+1)*bdCoeff(jj)
+ end
+ end
+ for jj = 1:length(adfCoeff)
+ if ii-jj <= 0 then
+ ySum = ySum + 0
+ else
+ ySum = ySum + yHat(ii-jj+1)*adfCoeff(jj)
+ end
+ end
+ yHat = [yHat; uSum+ySum]
+ end
+ tempStart = 1
+ if size(yHat,'r')- size(yData,'r') > 0 then
+ tempStart = size(yHat,'r')-size(yData,'r')+1
+ end
+ varargout(1) = yHat(tempStart:length(yHat))
+// plot(yHat(tempStart:length(yHat)),'m')
+// plot(yData)
+// xgrid()
+// pause
+endfunction