www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conlinear/getRelationValues.m

    function [L, R] = getRelationValues(obj, X, opt)
%GETRELATIONVALUES Return the comparison values for the constraint 
%
%  [L, R] = GETRELATIONVALUES(CON, X) returns the left- and right-hand side
%  values for the constraint equation.  X should be an array with nFactors(
%  CON) columns. L and R will be vectors with the same number of rows as X.
%  
%  GETRELATIONVALUES(CON, X, OPT) returns the specified values.  OPT must
%  be one of 'left', 'right', or 'both'.  The default setting is 'both',
%  which produces two outputs.
%
%  See also: CONBASE/GETRELATION.

%  Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin<3
    DOLEFT = true;
    DORIGHT = true;
else
    DOBOTH = strcmpi(opt, 'both');
    DOLEFT = DOBOTH || strcmpi(opt, 'left');
    DORIGHT = DOBOTH || ~DOLEFT;
end

% Calculate left-hand side
if DOLEFT
    X = pFilterFactors( obj, X );
    L = X*obj.A';
end

% Calculate right-hand side
if DORIGHT
    R = repmat(obj.b, size(X, 1), 1);
end

if ~DOLEFT
    % Output the right-hand side as the first output
    L = R;
end

if nargin<3
    opt = 'both';
end