Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB - why is it complaining about @-folders for classdef'd objects?

Tags:

oop

matlab

I've been writing OOP MATLAB code for quite some time. However, I'm now running MATLAB code on a Windows machine for the first time.

I have the following code:

classdef myClass < handle
    properties
        i
    end

    methods
        function obj = myClass()
            obj.i = 0;
        end

        function say(obj)
            obj.i = obj.i + 1;
            fprintf('This is time #%i you invoked me!\n', obj.i);
        end
    end
end

Seems pretty innocuous. I try to instantiate an object and I get this:

>> m = myClass;
Error using myClass
Error: File: myClass.m Line: 1 Column: 10
A class definition must be an "@" directory.

I've never used an @-folder in all my time writing OOP MATLAB code. My understand is it's required if class methods are written separately from the classdef file (mine's not) or if it's using the old-style MATLAB class syntax (mine's not).

I think I know what the deal is and I wanted to see if there's a workaround: My working directory is of the form

C:\Users\[email protected]\Documents\MATLAB

Is that @ throwing MATLAB off and making the computer think I'm in an @-folder? If it is, is there a workaround (aside making a new user on my computer, obviously - and that probably isn't doable)? If not, what is going on?

like image 456
Dang Khoa Avatar asked Oct 03 '12 21:10

Dang Khoa


1 Answers

Looks like yes, the @ in the middle of the folder is causing the error. I filed a bug report with The MathWorks.

like image 154
Dang Khoa Avatar answered Nov 01 '22 16:11

Dang Khoa