www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/mbcListString.m
function s = mbcListString(List,space,Last) %MBCLISTSTRING create comma separated string from cell array % % s = mbcListString(List); % s = mbcListString(List,space) % s = mbcListString(List,space,Last) % You can specify spaces after the comma and a joining word (and/or) to % use between the last two items. % Copyright 2009 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<2 space=''; end MainString = ['%s,',space]; s = sprintf(MainString,List{:}); s= s(1:end-1-length(space)); if nargin>2 && ~isempty(Last) pos = strfind(s,[',',space]); if ~isempty(pos) % add Last to link the last item (normally and/or) s = [s(1:pos(end)-1) ' ',Last,' ',s(pos(end)+1+length(space):end)]; end end