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

    function x = invcode(obj,x,factnum)
%INVCODE inverse coding transform
%
% xout = invcode(obj,x)

%  Copyright 2007 The MathWorks, Inc. 


if nargin<3
    factnum = 1:length(obj);
end
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).Scale + obj(j).Offset;
    end
else
    for i=1:n
        j = factnum(i);
        if obj(j).IsLinear
            x(:,i) =  x(:,i)/obj(j).Scale + obj(j).Offset;
        else
            % this branch does not jit
            T = obj(j).Transform;
            x(:,i) = T.Inv(x(:,i)/obj(j).Scale + obj(j).Offset);
        end
    end
end