Get environment variable in MATLAB
Last Updated :
06 Jul, 2021
In this article, we are going to discuss “Getting environment variable”, which can be done using getenv() function. The getenv() function is used to get the operating system environment variable.
Syntax:
value = getenv(name)
Parameters: This function accepts a parameter name parameter.
- name: This is the specified name for which environmental variable is going to be searched.
Return Value: It returns the operating system environment variable.
Example 1
Matlab
setenv( 'GFG' , 'C:\GFG' );
getenv( 'GFG' )
|
Output
ans = C:\GFG
Here the getenv() function returns the current environmental variable name “C:\GFG”.
Example 2
Matlab
setenv( 'a' , 'D:\geeksforgeeks\gfg' );
getenv( 'a' )
|
Output
ans = D:\geeksforgeeks\gfg
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...