Main Content

isenv

Determine if environment variable exists

    Description

    example

    tf = isenv(name) returns logical 1 (true) if name is an operating system environment variable. If name does not exist, then isenv returns logical 0 (false).

    On most UNIX® platforms, an environment variable can exist with an empty value (""). On the Microsoft® Windows® platform, setting the value of an environment variable to "" is equivalent to removing the variable.

    Examples

    collapse all

    Create environment variable myVar and check that it exists.

    setenv("myVar","myValue");
    isenv("myVar")
    ans = logical
       1
    
    

    Remove myVar and check that it no longer exists.

    unsetenv("myVar");
    isenv("myVar")
    ans = logical
       0
    
    

    Input Arguments

    collapse all

    Environment variable name, specified as a string scalar or character vector.

    Example: "PATH"

    Version History

    Introduced in R2022b

    See Also

    | | | | | |