www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffkeytable/addTableDatakeys.m

    function [obj, datakey] = addTableDatakeys(obj, varargin)
%ADDTABLEDATAKEYS Create new datakeys that are linked to table cells
%
%  [OBJ, DATAKEY] = ADDTABLEDATAKEYS(OBJ, R, C) adds new datakeys that are
%  linked to the cells indexed by the elemnts of (R, C).  R and C are
%  vectors of length N that define N new datakeys to be added.

%  Copyright 2000-2004 The MathWorks, Inc. and Ford Global Technologies, Inc.


L = uint32(sub2ind(obj.TableSize, varargin{:}));
L = L(:);

% Check that none of the table links already exist
if any(ismember(L, obj.DataKeyTable(:,1)))
    error(message('mbc:cgtradeoffkeytable:InvalidIndex'));
end

% Add new keys
[obj, datakey] = addDatakeys(obj, length(L));

% Link up table indices
obj.DataKeyTable((end - length(L) + 1):end,1) = L;