Why is MATLAB 6.1 (R12.1) for UNIX or LINUX unable to recognize my case-sensitive object created in Windows?

1 view (last 30 days)
Why is MATLAB 6.1 (R12.1) for UNIX or LINUX unable to recognize my case-sensitive object created in Windows?
I created a user-defined class in MATLAB that has a capital letter in the classname. I copied the same exact class directory onto both a Windows machine and a UNIX machine. When I define an object in this class in Windows and save it, I am not able to load it into UNIX or LINUX.
For example, my user-defined classname is "newClassName". I create an object and save it using the following code in Windows:
% Executed on Windows machine
obj = newClassName;
save datafile obj
I now load the object using the following code on a UNIX machine:
% Executed on a UNIX machine
load datafile
I get the following error:
Warning: Class 'newclassname' is an unknown object class. Object 'obj' of this
class has been converted to a structure.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Jan 2010
This enhancement has been made for Release 14 SP1 (R14SP1). For previous product releases, please read below for any possible workarounds:
The solution to this problem is to always use lowercase letters for classnames. Please note that this is no longer an issue with MATLAB 7.0 (R14).
On Windows, MATLAB normalizes classnames to be lowercase. This can be seen by applying the CLASS function to an object created by a constructor in a capitalized directory or constructor file. The result returned by CLASS on Windows will always be lowercase.
This is necessitated by the case-insensitive file system on Windows. Because of the case-insensitive file system on Windows, you could (for example) have a constructor @MYCLASS/MyClAsS.m, which contains the statement:
obj = class(s, 'mYcLaSs');
The object that results from this has to be able to use methods in @MYCLASS/, but also has to be useable with methods in @myclass/, @MyClass/, @mYcLASS/, etc. However, an object created with different capitalization of the classname argument to the CLASS function, from a directory or constructor file with a different capitalization than that above, must behave just like the object above.
If an object is saved to a MAT file, and the capitialization of the class directory is changed, then such an object when loaded from the MAT file needs to be able to use methods in the class directory, irrespective of it's changed capitalization.
These filesystem name-matching rules on Windows necessitate a normalized form for representing class names on Windows. MATLAB lowercases all class names to this normalized form.

More Answers (0)

Categories

Find more on Construct and Work with Object Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!