1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
|