CStrCatStr

版本 1.3.0.0 (11.1 KB) 作者: Jan
Cat 2 or 3 strings/cell strings C-MEX: 10 times faster than STRCAT
1.2K 次下载
更新时间 2010/2/10

查看许可证

Join 2 or 3 strings and cell strings 10 times faster than STRCAT

R = CStrCatStr(A, B) or R = CStrCatStr(A, B, C)
INPUT:
A, B, C: Strings or cell strings. At least one input must be a cell string.
OUTPUT:
R: Cell string with the same size as the input cell.

Comparison with Matlab's STRCAT:
- MEX version is about 10 times faster that STRCAT.
- CStrCatStr is limited to 2 or 3 inputs with at least one cell string.
- CStrCatStr conserves marginal spaces.
- STRCAT('A', {}) replies: {'A'}. CStrCatStr('A', {}) replies: {}.
- CStrCatStr treats char arrays as single string with linear index.

EXAMPLES:
CStrCatStr('a', {'a', 'b', 'c'}) % ==> {'aa', 'ab', 'ac'}
CStrCatStr({'a'; 'b'; 'c'}, '-') % ==> {'a-'; 'b-'; 'c-'}
CStrCatStr({' ', ''}, 'a', {' ', ''}) % ==> {' a ', 'a'}
CStrCatStr({'a', 'b'}, {'c'}) % ==> error: cells need equal size
FileDir = dir(Path); AbsName = CStrCatStr(Path, filesep, {FileDir.name});

Tested: Matlab 6.5, 7.7, 7.8, Win2K/XP, LCC2.4, LCC3.8, BCC5.5, 32 + 64 bit addressing.
Run unit-test TestCStrCatStr after compiling and for a speed test (see screen shot).
Compiled Mex: http://www.n-simon.de/mex

引用格式

Jan (2024). CStrCatStr (https://www.mathworks.com/matlabcentral/fileexchange/24341-cstrcatstr), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2009a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.3.0.0

32 + 64 bit addressing

1.2.0.0

Shorter description, sources are not changed

1.0.0.0