Home > functions > gui > preAnalysis > trial_extractor > private > vb_tag_util_find_tag.m

vb_tag_util_find_tag

PURPOSE ^

find tag object by name

SYNOPSIS ^

function [tag_obj, ix] = vb_tag_util_find_tag(tags, name)

DESCRIPTION ^

 find tag object by name
 [USAGE]
    [tag_obj, ix] = vb_tag_util_find_tag(tags, name);
 [IN]
    tags : tag object list
    name : tag name
 [OUT]
    tag_obj : found tag object.
         ix : Nth tag.

 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 [tag_obj, ix] = vb_tag_util_find_tag(tags, name)
0002 % find tag object by name
0003 % [USAGE]
0004 %    [tag_obj, ix] = vb_tag_util_find_tag(tags, name);
0005 % [IN]
0006 %    tags : tag object list
0007 %    name : tag name
0008 % [OUT]
0009 %    tag_obj : found tag object.
0010 %         ix : Nth tag.
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
0014 
0015 %
0016 % --- Previous check
0017 %
0018 if ~exist('tags', 'var') || isempty(tags)
0019     error('Specified tags are invalid.');
0020 end
0021 if ~exist('name', 'var') || isempty(name) || ~ischar(name)
0022     error('Specified tag name is invalid');
0023 end
0024 
0025 %
0026 % --- Main Procedure
0027 %
0028 tag_obj = [];
0029 ix = [];
0030 for k=1:length(tags)
0031     tag_name = vb_tag_get_tag_name(tags{k});
0032     if strcmp(tag_name, name)
0033         tag_obj = [tag_obj; tags{k}];
0034         ix = [ix; k];
0035     end
0036 end

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