Add package, class, or functions to current import list
import
adds the class name to the current import list. To refer to a class without
specifying the entire package name, use the PackageName
.ClassName
import
function
in your code.
The import list scope is defined as follows:
Function or script, including nested and local function — Scope is the function.
The scope of a script is the script body. The imports in a script are available only in the script body and are not available in the scopes which call the script. For example, executing a script containing imports at the command prompt does not make the imports available in the command window.
The import list of a function is persistent across calls to that
function and is cleared only when the function is cleared. For more
information, see the clear
function. Do not
call clear import
within a function or a
script.
Base workspace — Scope is code executed at the command prompt. To clear the base import list, type clear import
at the MATLAB® command prompt.
import
adds the specified package-based function. Use this syntax to shorten the name
of a specific function in a package without importing every function in the
package, which might cause unexpected name conflicts.PackageName
.FunctionName
import
adds the specified static method. Use this syntax to shorten the name of a
specific static method. PackageName
.ClassName
.staticMethodName
import
adds the specified package name. PackageName
.*PackageName
must be followed by .*
.
Avoid using this syntax, as importing packages brings an unspecified set of names into the local scope, which might conflict with names in the MATLAB workspace. One possible use for this syntax is to import a partial package name. Then when you call a function, you use a shorter package name which does not conflict with simple function names. For example, the matlab.io.hdf4.sd
package has a close
function, which can conflict with the MATLAB
close
function.
import
cannot load a Java® JAR package created by the MATLAB
Compiler SDK™ product.
Do not use import
in conditional statements inside a function. MATLAB preprocesses the import
statement before evaluating the variables in the conditional statements.
clear
| importdata
| load