Overload Char

Changes default behavior of [], +, - for char types.
283 Downloads
Updated 26 Jan 2011

View License

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 (2024). Overload Char (https://www.mathworks.com/matlabcentral/fileexchange/30194-overload-char), MATLAB Central File Exchange. Retrieved .

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

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0