summaryrefslogtreecommitdiff
path: root/iv.sci
diff options
context:
space:
mode:
authorpriyakedia2018-07-31 16:10:34 +0530
committerpriyakedia2018-07-31 16:10:34 +0530
commitdb25cb043776c50d0f0ee98636301906b065d8f0 (patch)
tree999773628035605e4963be2712401bf9836188a6 /iv.sci
parenta0084443a1d6a9bebd29a0860c7ae83c22f08002 (diff)
downloadFOSSEE-System-Identification-Toolbox-db25cb043776c50d0f0ee98636301906b065d8f0.tar.gz
FOSSEE-System-Identification-Toolbox-db25cb043776c50d0f0ee98636301906b065d8f0.tar.bz2
FOSSEE-System-Identification-Toolbox-db25cb043776c50d0f0ee98636301906b065d8f0.zip
examples included
Diffstat (limited to 'iv.sci')
-rw-r--r--iv.sci61
1 files changed, 53 insertions, 8 deletions
diff --git a/iv.sci b/iv.sci
index a819a4e..4c654f0 100644
--- a/iv.sci
+++ b/iv.sci
@@ -1,5 +1,50 @@
function varargout = iv(varargin)
+// Parameters Estimation of IV model by arbitrary instrumental variable method
+//
+// Calling Sequence
+// sys = iv(ioData,[na nb nk])
+// sys = iv(ioData,[na nb nk],instData)
+// Parameters
+// ioData : iddata or [outputData inputData] ,matrix of nx2 dimensions, type plant data
+// na : non-negative integer number specified as order of the polynomial A(z^-1)
+// nb : non-negative integer number specified as order of the polynomial B(z^-1)+1
+// nk : non-negative integer number specified as input output delay, Default value is 1
+// instData : arbitrary instrument variable matrix. The size of instriment variable must be equal to the size of outputData
+// sys : idpoly type polynomial have estimated coefficients of A(z^-1) and B(z^-1) polynomials
+//
+// Description
+// Fit IV model on given input output data
+// The mathematical equation of the IV model
+// <latex>
+// begin{eqnarray}
+// A(q)y(n) = B(q)u(n-k) + e(t)
+// end{eqnarray}
+// </latex>
+// It is SISO type model. Instrument variable method is use to estimate the cofficients. If user does not provide the arbitrary instrument variable matrix
+// then the program extracte it by using ARX method.
+//
+// sys ,an idpoly type class, have different fields that contains estimated coefficients, sampling time, time unit and other estimated data in Report object.
+//
+// Examples
+// u = idinput(1024,'PRBS',[0 1/20],[-1 1])
+// a = [1 0.2];b = [0 0.2 0.3];
+// model = idpoly(a,b,'Ts',0.1)
+// y = sim(u,model) + rand(length(u),1)
+// ioData = iddata(y,u,0.1)
+// sys = arx(ioData,[2,2,1])
+//
+// Examples
+// u = idinput(1024,'PRBS',[0 1/20],[-1 1])
+// a = [1 0.2];b = [0 0.2 0.3];
+// model = idpoly(a,b,'Ts',0.1)
+// y = sim(u,model) + rand(length(u),1)
+// ioData = [y,u]
+// sys = iv(ioData,[2,2,1])
+//
+// Authors
+// Ashutosh Kumar Bhargava, Bhushan Manjarekar
+
[lhs , rhs] = argn(0);
if ( rhs < 2 || rhs > 3) then
errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be 2 or 3"), "iv", rhs);
@@ -58,19 +103,19 @@ function varargout = iv(varargin)
end
phif = zeros(noOfSample,na+nb)
psif = zeros(noOfSample,na+nb)
- // arranging samples of y matrix
+ // arranging samples of y matrix
for ii = 1:na
phif(ii+1:ii+noOfSample,ii) = yData
psif(ii+1:ii+noOfSample,ii) = x
end
- // arranging samples of u matrix
+ // arranging samples of u matrix
for ii = 1:nb
phif(ii+nk:ii+noOfSample+nk-1,ii+na) = uData
psif(ii+nk:ii+noOfSample+nk-1,ii+na) = uData
end
lhs = psif'*phif
lhsinv = pinv(lhs)
- //pause
+ // pause
theta = lhsinv * (psif)' * [yData;zeros(n,1)]
ypred = (phif * theta)
ypred = ypred(1:size(yData,'r'))
@@ -79,12 +124,12 @@ function varargout = iv(varargin)
vcov = sigma2 * pinv((phif)' * phif)
t = idpoly([1; -theta(1:na)],[zeros(nk,1); theta(na+1:$)],1,1,1,1)
- // estimating the other parameters
- [temp1,temp2,temp3] = predict(z,t)
- [temp11,temp22,temp33] = pe(z,t)
+ // estimating the other parameters
+ [temp1,temp2,temp3] = predict(plantData,t)
+ [temp11,temp22,temp33] = pe(plantData,t)
estData = calModelPara(temp1,temp11,na+nb)
- //pause
+ // pause
t.Report.Fit.MSE = estData.MSE
t.Report.Fit.FPE = estData.FPE
t.Report.Fit.FitPer = estData.FitPer
@@ -93,6 +138,6 @@ function varargout = iv(varargin)
t.Report.Fit.nAIC = estData.nAIC
t.Report.Fit.BIC = estData.BIC
t.TimeUnit = unit
- //sys = t
+ // sys = t
varargout(1) = t
endfunction