String comparison

版本 1.0.0.0 (1.6 KB) 作者: ChinSoon Lim
Compares 2 strings. Output is identical to that of C string library.
1.1K 次下载
更新时间 2016/4/10

查看许可证

Compares 2 strings, str1 and str2 and return -1 if str1 < str2, 0 if str1==str2 and 1 if str1 > str2. output is identical to that of C string library.
Same idea as files listed in acknowledgments. The difference is that this implementation is faster since it uses mex function.
Type mex strcmpC.c at the MATLAB prompt to generate the mex file. Then call strcmpC like any MATLAB function.
Example usage:
strcmpC('1234','2345535')
ans =
-1
Source code heavily references a mex example. See mxmalloc.c.
Type the following command in MATLAB prompt to see mxmalloc.c
edit([matlabroot '/extern/examples/mx/mxmalloc.c']);

引用格式

ChinSoon Lim (2025). String comparison (https://www.mathworks.com/matlabcentral/fileexchange/23375-string-comparison), MATLAB Central File Exchange. 检索时间: .

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

参考作品: Compare Strings (C-convention), lexcmp

Community Treasure Hunt

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

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

submit another update that removes the GNU License statement from your Zip as requested by admin
Updated as requested by admin

submit another update that removes the GNU License statement from your Zip as requested by admin