www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgsumobjective/checkInputSizes.m

    function [Status, Message] = checkInputSizes(obj, InSize)
%CHECKINPUTSIZES Check the compatibility of input lengths
%
%  [STATUS, MESSAGE] = CHECKINPUTSIZES(OBJ, INSIZE) checks that the
%  proposed lengths of the inputs, INSIZE, are acceptable and can produce a
%  valid set of outputs.  STATUS is a vector the same length as INSIZE that
%  contains integer codes indicating whether that input is acceptable.  A
%  status of 0 indicates no problem, 1 indicates a warning issue and 2
%  indicates an critical problem.  MESSAGE is a string that describes the
%  overall problem and should be non-empty whenever any inputs have a
%  non-zero status.

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


Status = zeros(size(InSize));

maxIn = max(InSize);
if ~all(InSize==maxIn | InSize==1)
    % Flag the length>1 inputs as error problems
    Status(InSize>1) = 2;
    Message = 'Inputs must be scalar or have a common number of values.';    
else
    Message = '';
end