import
Import model classes
Parent Section: none (top-level)
Syntax
import namespace_or_class; import namespace.*;
Description
The import statements allow access to model class or function names
            defined in other scopes (namespaces) without a fully qualified reference. You must place
                import statements at the beginning of a Simscape™ file. 
There are two types of import statement syntaxes. One is a
            qualified import, which imports a specific namespace, class, or function:
import namespace_or_class;
The other one is an unqualified import, which imports all subnamespaces, classes, and functions under the specified namespace:
import namespace.*;
The namespace or class name must be a full path name, starting from the library root (the top-level namespace folder name) and containing subnamespace names, as necessary.
Import statements are subject to the following constraints:
- The imported name must be a full path name, starting from the library root, even if the - importstatement is used in a component class defined under the same namespace as the domain or component class that is being imported.
- You must place - importstatements at the beginning of a Simscape file. The scope of imported names is the entire Simscape file, except the- setupsection.
- In qualified import statements, the imported name can refer to a subnamespace, a model class (domain class or component class), or a function. For example, in the - import A.B.C;statement,- Ccan be either a subnamespace name, a class name, or a function name. In unqualified import statements, the imported name must refer to a namespace or subnamespace. For example, in the- import A.B.*;statement,- Bmust be a subnamespace name (of namespace- A).
- It causes a compilation error if an unqualified imported name is identical to other names within the same scope, provided the duplicate name is in use. For example, assume that subnamespaces - A.Band- A.B1both contain a component class- C. This code:- import A.B.C; import A.B1.*; component M components (ExternalAccess=observe) c = C; end end- causes a compile-time error. However, the following code is legal (provided that - Dis defined only in- A.B) because- Cis not used:- import A.B.C; import A.B1.*; component M components (ExternalAccess=observe) d = D; end end- This code is also legal: - import A.B; import A.B1; component M components c1 = B.C; c2 = B1.C; end end- because you import two different names into this scope ( - Band- B1), and access the two different component classes- Cthrough their parent classes- Band- B1.
Examples
Version History
Introduced in R2013b