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

    function p = pev(m,X)
%PEV Prediction error variance of the model
%    [PEV, Y] = PEV( MODEL, X );
%    X is a(N-by-NF) array, where NF is the number of inputs, and N the
%    number of points to evaluate the model at.
%
%  See also EvalModel, predint

%  Copyright 2009-2014 The MathWorks, Inc. and Ford Global Technologies, Inc.


X = xregexportmodel.convertToDouble(X);

doActiveFactors = ~isempty(m.ActiveFactors);

% divide into local and operating points
if doActiveFactors 
    Xlocal = X;
else
    Xlocal = X(:,1:m.NumLocalInputs);
end

Neval = size(X,1);
Index = findOpPoints(m,X);

p = NaN(Neval,1);
for i=1:max(Index)
    pts = i==Index;
    if any(pts)
        if ~doActiveFactors
            p(pts) = pev(m.ModelList,i,Xlocal(pts,:));
        else
            p(pts) = pev(m.ModelList,i,Xlocal(pts,m.ActiveFactors{i}));
        end
    end
end