www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoppoint/AddRow.m
function p = AddRow(p,data,ind,no) %ADDROW Add row(s) of data to operating point set % % OP = ADDROW(OP) appends a row to operating point OP. Inputs are set to % the set point where possible or zero otherwise. % % OP = ADDROW(OP, DATA) appends DATA to the operating point set. DATA % must have the same number of columns as there are factors in OP. % Specifying DATA as empty adds a single row of data with inputs set to % set point or zero. % % OP = ADDROW(OP, DATA, IND) inserts DATA after the IND-th existing row. % IND = 0 inserts DATA at the first operating point. % % OP = ADDROW(OP, DATA, IND, NO) specifies the number of rows to add to % the operating point set if DATA is empty. % % See also CGOPPOINT/APPEND % Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc. % Do not add rows to an empty operating point set if isempty(p) return end if nargin < 4 no = 1; end cols = get(p,'numfactors'); pts = get(p,'numpoints'); if (nargin==1) || isempty(data) % Initialise data to zeros data = zeros(no,cols); % Indices of valid inputs inpIdx = p.factor_type == 1 & isvalid(p.ptrlist); if any(inpIdx) % Indices of valid inputs that are sources inpIdx(inpIdx) = parrayeval(p.ptrlist(inpIdx), ... @issource, [], mbclogical); if any(inpIdx) % Set points for the input dataRow = parrayeval(p.ptrlist(inpIdx), @getnomvalue, ... {}, mbcdouble); data(:, inpIdx) = repmat(dataRow, no, 1); end end elseif nargin>1 if size(data,2)~=cols if size(data,1)==cols data = data'; else error(message('mbc:cgoppoint:InvalidArgument3')); end end end if nargin<3 ind = pts; else if (ind<0) || (ind>pts) error(message('mbc:cgoppoint:InvalidArgument4')); end end d = p.data; p.data = [d(1:ind,:) ; data ; d(ind+1:end,:)]; % Convert all input variables to be a block of data p = convertAllInputsToBlock(p); % Ensure the formulae dependencies are correct by calling checkGroup p = CheckGroup(p);