@ folders - what is it?

3 views (last 30 days)
Grzegorz Knor
Grzegorz Knor on 9 Sep 2011
Hi,
I am looking for information about the @ - directories, I've found only: http://www.mathworks.com/help/techdoc/matlab_oop/brfynrp- 1.html#brfynrp-2
So I have question:
Why do you need these folders?
Only for organizing classes?
Or is there any other application?

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 9 Sep 2011
The second question is the answer: yes, it's "only" for organizing classes.
You can either use only one file or several files (each one method) in a class folder (@classname). Or a mixture. Take a look at
web([docroot '/techdoc/matlab_oop/brqy4ox-1.html'])
Titus
  2 Comments
Grzegorz Knor
Grzegorz Knor on 9 Sep 2011
Thanks.
I couldn't understand the 'strange' behavior of Matlab :)
pwd
% ../@test
ls
% not_test.m test.m
type test
% function test
% disp(mfilename)
% not_test
type not_test
% function not_test
% display(mfilename)
test
% ??? Undefined function or variable 'test'.
not_test
% ??? Undefined function or variable 'not_test'.
cd ..
test
% test
% ??? Undefined function or variable 'not_test'.
% Error in ==> test.test at 3
% not_test
not_test
% ??? Undefined function or variable 'not_test'.
Jan
Jan on 9 Sep 2011
@Titus: I do not agree. E.g. @cell folders are helpful to apply a specific function for CELL input. I would not call this "organizing classes", but on the other hand, a CELL is a built-in class also.

Sign in to comment.

More Answers (1)

Jan
Jan on 9 Sep 2011
The @-folders can be used to call a specific function depending on the class of the input. E.g. you can create two functions with the same name, but in different @-folders:
D:\MFiles\@double\show.m
D:\MFiles\@cell\show.m
Now show(8) calls @double/show, while show({8}) calls @cell/show. This is equivalent to the usage with objects.
Note, that only 'D:\MFiles' is included in the MATLAB path in this case, and not the @-folders.

Tags

Products

Community Treasure Hunt

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

Start Hunting!