summaryrefslogtreecommitdiff
path: root/misdata.sci
diff options
context:
space:
mode:
authorttt2018-07-09 16:54:44 +0530
committerttt2018-07-09 16:54:44 +0530
commite5e316e1958e27696d7670e2492992d34ff38b68 (patch)
tree8dab5cc24e31921cfb3c44444d48cfbfd3ff76f8 /misdata.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 'misdata.sci')
-rw-r--r--misdata.sci41
1 files changed, 41 insertions, 0 deletions
diff --git a/misdata.sci b/misdata.sci
new file mode 100644
index 0000000..c1ced50
--- /dev/null
+++ b/misdata.sci
@@ -0,0 +1,41 @@
+function varargout = misdata(varargin)
+ [lhs,rhs] = argn(0)
+//------------------------------------------------------------------------------
+// checking the number of inputs
+ if rhs <> 1 then
+ error(msprintf(gettext("%s:Wrong number of input arguments.\n"),"misdata"))
+ end
+//------------------------------------------------------------------------------
+ ioData = varargin(1)
+ if typeof(ioData) <> "iddata" then
+ error(msprintf(gettext("%s: Plant input data must be ""iddata"" type. "),"misdata"))
+ end
+ inputMat = ioData.InputData;inputMat = linearINTRP(inputMat,abs(ioData.Ts));ioData.InputData = inputMat;
+ outputMat = ioData.OutputData;outputMat = linearINTRP(outputMat,abs(ioData.Ts));ioData.OutputData = outputMat;
+ varargout(1) = ioData
+endfunction
+
+function varargout = linearINTRP(matData,Ts)
+ // looking for overall nan values
+ nanData = isnan(matData);nanIndex = find(nanData == %T)
+ if ~size(nanIndex,'*') then
+ varargout(1) = matData
+ else
+ tempMat = []
+ matSize = size(matData,'r')
+ // looking for nan in each column
+ for ii = 1:size(matData,'c')
+ nanData = isnan(matData(:,ii));nanIndex = find(nanData == %T);
+ if ~size(nanData,'*') then
+ tempMat = [tempMat matData(,ii)]
+ else
+ timeData = (linspace(1*Ts,matSize*Ts , matSize))';
+ nanMat = isnan(matData(:,ii));
+ data = matData(:,ii)
+ data(nanMat) = interp1(timeData(~nanMat), data(~nanMat), timeData(nanMat));
+ tempMat = [tempMat data]
+ end
+ end
+ varargout(1) = tempMat
+ end
+endfunction