Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop Embedded Coder   

Custom Storage Class Implementation

You can skip this section unless you want to ship custom storage class definitions in an uneditable format, or you intend to bypass the Custom Storage Class designer and work directly with files that contain custom storage class definitions.

The file that defines a package's custom storage classes is called a CSC registration file. The file is always named csc_registration and resides in the @package directory that defines the package. A CSC registration file can be a P-file (csc_registration.p) or an M-file (csc_registration.m). A built-in package defines custom storage classes in both a P-file and a functionally equivalent M-file. A user-defined package initially defines custom storage classes only in an M-file.

P-files take precedence over M-files, so when MATLAB looks for a package's CSC registration file and finds both a P-file and an M-file, MATLAB loads the P-file and ignores the M-file. All capabilities and tools, including the Custom Storage Class Designer, then use the CSC definitions stored in the P-file. P-files cannot be edited, so all CSC Designer editing capabilities are disabled for CSCs stored in a P-file. If no P-file exists, MATLAB loads CSC definitions from the M-file. M-files are editable, so all CSC Designer editing capabilities are enabled for CSCs stored in an M-file.

Because CSC definitions for a built-in package exist in both a P-file and an M-file, they are uneditable. You can make the definitions editable by deleting the P-file, but The MathWorks discourages modifying CSC registration files or any other files under matlabroot. The preferred technique is to create user-defined packages, data classes, and custom storage classes, as described in Subclassing Simulink Data Classes and this chapter.

The CSC Designer saves CSC definitions for user-defined packages in an M-file, so the definitions are editable. You can make the definitions uneditable by using the pcode function to create an equivalent P-file, which will then shadow the M-file. However, you should preserve the M-file if you may need to make further changes, because you cannot modify CSC definitions that exist only in a P-file.

You can also use tools or techniques other than the Custom Storage Class Designer to create and edit M-files that define CSCs. However, The MathWorks discourages this practice, which is vulnerable to syntax errors and can give unexpected results if a shadowing P-file exists. When MATLAB finds an older P-file that shadows a newer M-file, it displays a warning in the MATLAB Command Window.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS