Home > utility > strJoin.m

strJoin

PURPOSE ^

STRJOIN Join a token list with the given delimiter to generate a string

SYNOPSIS ^

function str = strJoin(tokenList, delimiter)

DESCRIPTION ^

 STRJOIN Join a token list with the given delimiter to generate a string
    Usage:
    str = strJoin(tokenList, delimiter)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function str = strJoin(tokenList, delimiter)
0002 % STRJOIN Join a token list with the given delimiter to generate a string
0003 %    Usage:
0004 %    str = strJoin(tokenList, delimiter)
0005 
0006 %    Roger Jang, 20030331
0007 
0008 if nargin==0; selfdemo; return; end
0009 if length(tokenList)==0; str=''; return; end
0010 if length(tokenList)==1; str=tokenList{1}; return; end
0011 
0012 str=tokenList{1};
0013 for i=2:length(tokenList)
0014     str=[str, delimiter, tokenList{i}];
0015 end
0016 
0017 % ====== Self demo
0018 function selfdemo
0019 tokenList={'This', 'is', 'a', 'test'};
0020 str=feval(mfilename, tokenList, '-');
0021 tokenList
0022 fprintf('After running "str=split(tokenList, ''-'')":\n');
0023 str

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003