Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@folder and +folder

Tags:

matlab

What is the meaning of the following folder names in MATLAB?

  • @folder
  • +folder

I've created a class Tata.m which uses the classdef syntax. Should I put it in an @folder or a +folder?

I've looked at the documentation but it is not really clear in which cases the @folder should be used and in which cases the +folder should be used.

like image 275
lola Avatar asked Mar 20 '12 05:03

lola


People also ask

What is difference between directory and folder?

With a command-line interface (e.g., MS-DOS or Linux), you would say directory instead of folder as a directory is mapped to a physical location on a storage medium. A way to remember the difference between the two is when viewing files and folders in Windows, they have pictures.

What do you mean by file and folder?

A file is the common storage unit in a computer, and all programs and data are "written" into a file and "read" from a file. A folder holds one or more files, and a folder can be empty until it is filled. A folder can also contain other folders, and there can be many levels of folders within folders.

What is a folder and sub folder?

A subfolder is a folder stored inside another folder. Subfolders help you organize your files more completely. Each subfolder should be used to store files related to each other. For example, you might have one folder for files related to a job search.

What is the difference between drive and folder?

Answer: Answer: All the data on your hard drive consists of files and folders. The basic difference between the two is that files store data, while folders store files and other folders. The folders, often referred to as directories, are used to organize files on your computer.


1 Answers

The +folder piece is a MATLAB package folder. If you place Tata.m in a location like +folder/Tata.m, it will be known to MATLAB as the class folder.Tata. If you place it in a folder like someOtherFolder/Tata.m, or someOtherFolder/@Tata/Tata.m, it will be known to MATLAB as Tata.

It can be useful to place a classdef file in a class directory like @Tata to allow you to put the definition of some (or all) methods in separate files.

The doc has more details.

EDIT: To attempt to clarify the @ directories: historically, a class Tata with methods methodOne and methodTwo would require the following files:

somePlaceOnThePath/@Tata/Tata.m somePlaceOnThePath/@Tata/methodOne.m somePlaceOnThePath/@Tata/methodTwo.m 

In the "new" object system, you can still use the layout above without modification. At the other extreme, you can place the entire implementation of Tata in a single classdef block in:

somePlaceOnThePath/Tata.m 

If you have some large methods, or want to split up the implementation of the class Tata into several files to make parallel development simpler, you can take use a classdef like this:

%# somePlaceOnThePath/@Tata/Tata.m: classdef Tata     methods          result = methodTwo(obj, arg)           function methodOne(obj)              disp('hello from methodOne');          end     end end 

And also

%# somePlaceOnThePath/@Tata/methodTwo.m: function result = methodTwo(obj, arg) % do stuff with obj and arg end 

Strictly speaking, the advance declaration of methodTwo in the classdef is optional because it's using the default access specifiers. If you wanted to have methodTwo be a private method, you could place it in a methods (Access = private) block.

like image 53
Edric Avatar answered Oct 04 '22 13:10

Edric