www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@mbcinputfactor/code.m

    function x = code(obj,x,factnum)
%CODE coding transform
%
% xout = code(obj,x)

%  Copyright 2007 The MathWorks, Inc. 

       
n = length(factnum);
allin = true;
for i=1:n
    j = factnum(i);
    allin = allin && obj(j).IsLinear;
end

if allin
    % This loop is separated so the code is jitted
    for i=1:n
        j = factnum(i);
        x(:,i) = (x(:,i)-obj(j).Offset)*obj(j).Scale;
    end
else
    for i=1:n
        j = factnum(i);
        if obj(j).IsLinear
            x(:,i) = (x(:,i)-obj(j).Offset)*obj(j).Scale;
        else
            % this branch does not jit
            T = obj(j).Transform;
            x(:,i) = (T.Fcn(x(:,i))-obj(j).Offset)*obj(j).Scale;
        end
    end
end