isenv

Tests whether an environment variable is defined.

Category: Environment and Settings > System Commands

Syntax

tf = isenv(name)

Returns true when the variable name exists in the process environment.

Description

isenv gives a direct yes or no, without reading the value. Variables created with setenv count; variables removed with unsetenv do not.

Input arguments

name
Variable name, as a character vector or string scalar.

Output arguments

tf
Logical scalar.

Example

Defined or not

disp(isenv('MY_FLAG'))
setenv('MY_FLAG', '1');
disp(isenv('MY_FLAG'))
unsetenv('MY_FLAG');
disp(isenv('MY_FLAG'))
Output
   0
   1
   0

See also

getenv setenv unsetenv loadenv