# 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

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

## See also

[setenv](setenv), [searchenv](searchenv).

## History

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

## Author

Allan CORNET
