MATLAB: How to Use a Custom Class with the Same Name as a built-in MATLAB Class

MATLAB

How can I use a custom class with the same name as a built-in MATLAB class?

Best Answer

Due to how MATLAB loads classes, this is not possible.
A workaround is to rename the custom class.
To update old MAT files which contain instances of the custom class (before MATLAB introduced the built-in class), see the attached function file "MATconvert.m" as an example of a conversion function. Then follow the steps below:
1. Using a version of MATLAB before the built-in class was introduced:
2. Create the renamed custom class (newClass), and have both versions of the custom class available (oldClass and newClass)
3. Modify the conversion function to dig through your data structures to replace any instances of oldClass with the newClass
4. Run the conversion function on all old MAT files