Compare Strings (C-convention)

version (412 Bytes) by Stijn Helsen
This function compares two strings using C-convention.


Updated 22 Sep 2003

No License

This (old) function compares two strings and gives an output similar to the C-function strcmp.
Unlike the MATLAB strcmp function the strings are compared in the alphabetical order.


c : -1 if s1<s2, 0 if s1==s2, +1 if s1>s2.

(This is an old function, which I wanted to supply now....)

Cite As

Stijn Helsen (2022). Compare Strings (C-convention) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R10
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: lexcmp, String comparison

Community Treasure Hunt

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

Start Hunting!