Home > vbmeg > functions > common > utility > vb_table_delete.m

vb_table_delete

PURPOSE ^

delete record from table.

SYNOPSIS ^

function [tbl] = vb_table_delete(tbl, key)

DESCRIPTION ^

 delete record from table.
 [USAGE]
    [tbl] = vb_table_delete(tbl, key);
 [IN]
    tbl : table data.
    key : key             [string]
 [OUT]
    tbl : updated table data.

 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 [tbl] = vb_table_delete(tbl, key)
0002 % delete record from table.
0003 % [USAGE]
0004 %    [tbl] = vb_table_delete(tbl, key);
0005 % [IN]
0006 %    tbl : table data.
0007 %    key : key             [string]
0008 % [OUT]
0009 %    tbl : updated table data.
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
0016 %
0017 if ~exist('tbl', 'var')
0018     error('tbl is a required parameter.');
0019 end
0020 if ~exist('key', 'var')
0021     error('key is a required parameter.');
0022 end
0023 if ~ischar(key)
0024     error('key should be string');
0025 end
0026 
0027 %
0028 % --- Main Procedure
0029 %
0030 if ~isempty(tbl)
0031     ix = strmatch(key, {tbl.key}, 'exact');
0032     if ~isempty(ix)
0033         tbl(ix) = [];
0034     end
0035 end
0036 
0037 %
0038 % --- After check
0039 %
0040 if nargout ~= 1
0041     error('you need to receive an updated table data.');
0042 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005