<< createGUID OS functions hostname >>

getenv


Get the value of an environment variable.


Syntax


s = getenv(env_name)

Input argument


env_name

string scalar, character vector, string array, cell array of character vectors: environment variable name.

Output argument


s

string scalar, character vector, string array, cell array of character vectors: the environment variable value.

Description


getenv returns the value of an environment variable if it exists.

If the environment variable does not exist, it will return ''.

If env_name is a nonscalar cell array of character vectors or string array, then val has the same dimensions and type as env_name.

If env_name is a string scalar, then s is a character vector.

Example


getenv('OS')
getenv('myenvvar')
getenv(["PATH"; "OS"])
getenv({'PATH'; 'OS'})

See also


setenv, searchenv.

History


Version Description
1.0.0 initial version
1.4.0 Retrieve the values of several environment variables.

Author


Allan CORNET

<< createGUID OS functions hostname >>