Home > lattice > settags.m

settags

PURPOSE ^

SETTAGS sets the 'Tag' field in AT lattice elements

SYNOPSIS ^

function LATTICE = settags(LATTICE,INDEX,tag,varargin)

DESCRIPTION ^

SETTAGS sets the 'Tag' field in AT lattice elements
 LATTICE = SETTAGS(LATTICE, INDEX, TAG) 
   INDEX can be integer AT index or a string famly name
   TAG is a string tag or a cell array of strings
 LATTICE = SETTAGS(LATTICE, INDEX, TAG, 'append') 
   appends to existing tags

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function LATTICE = settags(LATTICE,INDEX,tag,varargin)
0002 %SETTAGS sets the 'Tag' field in AT lattice elements
0003 % LATTICE = SETTAGS(LATTICE, INDEX, TAG)
0004 %   INDEX can be integer AT index or a string famly name
0005 %   TAG is a string tag or a cell array of strings
0006 % LATTICE = SETTAGS(LATTICE, INDEX, TAG, 'append')
0007 %   appends to existing tags
0008 
0009 if ischar(INDEX)
0010     INDEX = findcells(LATTICE,'FamName',INDEX);
0011     if isempty(INDEX)
0012         error(['Family ''',fname,''' is not found']);  
0013     end
0014 end
0015 
0016 tag = reshape(cellstr(tag),1,[]);
0017 
0018 if nargin <=3
0019     for i = INDEX
0020         LATTICE{i}.Tag = tag;
0021     end
0022 elseif strcmpi(varargin{1},'append')
0023     for i = INDEX
0024         if isfield(LATTICE{i},'Tag')
0025             LATTICE{i}.Tag = reshape(cellstr(LATTICE{i}.Tag),1,[]);
0026             LATTICE{i}.Tag = union(LATTICE{i}.Tag, tag);
0027         else
0028             LATTICE{i}.Tag = tag;
0029         end
0030         
0031     end
0032 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005