strncmpr

버전 1.0.0.1 (11 KB) 작성자: Jan
Compare last N chars of strings or cell strings (fast C-Mex)
다운로드 수: 1K
업데이트 날짜: 2022/2/25

라이선스 보기

Compare last N chars of strings or cell strings
== FOR OLD MATLAB VERSIONS ONLY!
== Use EndsWith() in modern versions!
Input and output equal Matlab's STRNCMP/STRNCMPI, but the strings are compared from right to left.
T = strncmpr(S1, S2, N) or T = strncmpir(S1, S2, N)
INPUT:
S1, S2: Strings or cell strings.
N: Number of characters to compare.
OUTPUT:
T: Logical array, TRUE if the last N characters are equal, FALSE otherwise.
For STRNCMPIR the case is ignored.
Comparing just two strings in the backward direction can be done in Matlab with a fair efficiency. But for cell strings, this C-Mex is much faster than equivalent Matlab methods: e.g. 3% processing time for comparing a string with a {1 x 100} cell, 1% for {1 x 1000}. I apply it to identify the extensions of file names stored in cell strings.
Call the unit-test function Teststrncmpr to check validity and speed.
Tested: Matlab 6.5, 7.7, 7.8, WinXP, compatibility to Linux and OS-X assumed.
Compiler: LCC2.4/3.8, BCC5.5, OpenWatcom 1.8, MSVC 2008.
It is assumed that wchar_t has the same size as mxChar.
Pre-compiled Mex: http://www.n-simon.de/mex
I'd appreciate suggestions for improvements and bug reports sent through email - thanks.

인용 양식

Jan (2024). strncmpr (https://www.mathworks.com/matlabcentral/fileexchange/27032-strncmpr), 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.0.0.1

Mention EndsWith

1.0.0.0