Home > functions > gui > batch > batch_variable_table > vb_batch_variable_table_add_column.m

vb_batch_variable_table_add_column

PURPOSE ^

added new column

SYNOPSIS ^

function [obj, errmsg] =vb_batch_variable_table_add_column(obj, new_column_name)

DESCRIPTION ^

 added new column
 [USAGE]
    obj = vb_batch_variable_add_column(<obj>, <new_column_name>);
 [IN]
                obj : vb_batch_variable_table object
    new_column_name : new column name such as '$SUBJECT' [STRING]
 [OUT]
       obj : vb_batch_variable_table object
    errmsg : if error is occured, reason will be contained.

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [obj, errmsg] = ...
0002     vb_batch_variable_table_add_column(obj, new_column_name)
0003 % added new column
0004 % [USAGE]
0005 %    obj = vb_batch_variable_add_column(<obj>, <new_column_name>);
0006 % [IN]
0007 %                obj : vb_batch_variable_table object
0008 %    new_column_name : new column name such as '$SUBJECT' [STRING]
0009 % [OUT]
0010 %       obj : vb_batch_variable_table object
0011 %    errmsg : if error is occured, reason will be contained.
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 
0016 %
0017 % --- Previous check
0018 %
0019 if ~exist('obj', 'var')
0020     error('obj is a required parameter.');
0021 end
0022 if ~exist('new_column_name', 'var')
0023     error('new_column_name is a required parameter.');
0024 end
0025 if ~ischar(new_column_name) || isempty(new_column_name)
0026     error('invalid column name is given');
0027 end
0028 
0029 %
0030 % --- Main Procedure
0031 %
0032 errmsg = [];
0033 
0034 ix = strmatch(new_column_name, obj.column_name_list, 'exact');
0035 if ~isempty(ix)
0036     errmsg = 'Specified variable name already exists.';
0037     warning(errmsg);
0038 else
0039     % Add column
0040     [M, N] = size(obj.table);
0041     obj.table = [obj.table, cell(M,1)];
0042     obj.column_name_list{1, N+1} = new_column_name;
0043 end
0044 
0045 %
0046 % --- After check
0047 %
0048 if nargout < 1
0049     error('function caller should receive this object.');
0050 end

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005