www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffnode/addNewTable.m
function [obj, pTable, OK] = addNewTable(obj, sName, DefValue) %ADDNEWTABLE Create a new table and add to the tradeoff % % [OBJ, PTABLE, OK] = ADDNEWTABLE(OBJ, NAME) creates a new table and adds % it to the tradeoff session. PTABLE is the pointer to the new table. OK % indicates whether a new table was successfully created: if OK is false % then PTABLE will be a null pointer. % % [OBJ, PTABLE, OK] = ADDNEWTABLE(OBJ, NAME, DEFVALUE) specifies a value % to initialise the table with. If not specified, the table will contain % zeros. % % It is not possible to create a new table when the tradeoff is empty (no % tables have yet been added) so in this case OK will always be false. % Copyright 2000-2008 The MathWorks, Inc. and Ford Global Technologies, Inc. if numTables(obj)==0 pTable = null(xregpointer); OK = false; return end if nargin<3 DefValue = 0; end % Create new table that has same normalizers as current tables and is the % same size tbl_current = obj.Tables(1).info; pTable = cglookuptwo(sName, DefValue.*ones(getTableSize(tbl_current)), ... get(tbl_current, 'x'), get(tbl_current, 'y')); % Add table to project addtoproject(obj, pTable); % Add to tradeoff [obj, OK] = addTable(obj, pTable, true);