Overload Char

Changes default behavior of [], +, - for char types.

You are now following this Submission

This set of functions overloads horzcat([]), plus(+), and minus(-) for char types.

Using the builtin functions:
['a',98,'c'] -> 'abc'
'x'+1 -> 121
'x'-1 -> 119

Using the overloaded functions:
['a',98,'c'] -> 'a98c'
'x'+1 -> 'y'
'x'+ -1 -> 'w'
'x'-1 -> ''
'x'+'x' -> 'xx' %concatenate strings
'abc'-'b' -> 'ac' %removes token
'Hello World!' - 'World!' + 'Matlab!' -> 'Hello Matlab!'

To install, unzip somewhere and add the 'char_overloading' directory to your path. Do not add the '@char' directory to your path.
Installing does not enable this functionality until ToggleCharOverloading('on') is called.

Using ToggleCharOverloading from within functions does not work as intended. It is also written for Windows systems, but can be modified for Unix systems.

All functions are heavily documented, and lightly tested. It does not seem to break anything, but there is a possibility that something important may stop working or change its behavior.
Use at your own risk.

Cite As

Jon Danisch (2026). Overload Char (https://www.mathworks.com/matlabcentral/fileexchange/30194-overload-char), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0