summaryrefslogtreecommitdiff
path: root/spa.sci
diff options
context:
space:
mode:
Diffstat (limited to 'spa.sci')
-rw-r--r--spa.sci30
1 files changed, 26 insertions, 4 deletions
diff --git a/spa.sci b/spa.sci
index 4b91cc9..7decc89 100644
--- a/spa.sci
+++ b/spa.sci
@@ -1,4 +1,26 @@
function varargout = spa(varargin)
+// Use spectral analysis to estimate frequency response
+//
+// Calling Sequence
+// frdData = spa(plantData,winSize,Freq)
+// Parameters
+// plantData : iddata type
+// winSize : non-neative integer number
+// Freq : frequency points to evaluate the response
+// frdData : frd type object
+// Description
+// spa function does the estimation of the frequency response of iddata of a plant using the spectral analysis. Hanning window is used in spectral
+// analysis. Default size of the window is minimum of the number of sample divided by 10 or 30. The default frquency point is %pi x (1:128)/(sampling time x 128).
+// Examples
+// a = [1 0.2];b = [0 0.2 0.3];
+// sys = idpoly(a,b,'Ts',0.1)
+// u = idinput(1024,'PRBS',[0 1/20],[-1 1])
+// y = sim(u,sys)+rand(1024,1)
+// plantData = iddata(y,u,0.1)
+// frdData = spa(plantData)
+// Authors
+// Bhushan Manjarekar, Ashutosh Kumar Bhargava
+
[lhs , rhs] = argn();
if ( rhs < 1 || rhs > 3 ) then
errmsg = msprintf(gettext("%s: Wrong number of input arguments" ),"spa");
@@ -10,7 +32,7 @@ function varargout = spa(varargin)
plantData = varargin(1)
windowSize = %F
inputFreq = %F
-//------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------
// arranging the plant data
inputData = plantData.InputData;
if ~size(inputData,"*") then
@@ -20,7 +42,7 @@ function varargout = spa(varargin)
if ~size(outputData,"*") then
error(msprintf(gettext("%s:Output data must be non-zero vector. \n"),"spa"))
end
-//------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------
N = size(inputData,'r')
nout = size(outputData,'c')
nin = size(inputData,'c')
@@ -43,10 +65,10 @@ function varargout = spa(varargin)
phiY = spaCalculation(inputFreq,Ryy,M)
temp = phiY
for jj = 1:nin
- phiYU = spaCalculation(inputFreq,Ryu,M)//sapply(freq, cov2spec, Ryu[i, j, ], M)
+ phiYU = spaCalculation(inputFreq,Ryu,M)// sapply(freq, cov2spec, Ryu[i, j, ], M)
phiU = spaCalculation(inputFreq,Ruu,M)
G = [G phiYU./phiU]
- //pause
+ // pause
temp = temp - phiYU .* conj(phiYU)./phiU
end
spect = [spect temp]