MATLAB 도움말 센터
Remove environment variable
Since R2022b
unsetenv(varname)
unsetenv(varname) removes the operating system environment variable varname. If any elements in varname do not exist, then unsetenv has no effect.
varname
unsetenv
example
collapse all
Create environment variable myVar, and then check that it exists.
myVar
setenv("myVar","myValue"); isenv("myVar")
ans = logical 1
Remove myVar, and then check that it no longer exists.
unsetenv("myVar"); isenv("myVar")
ans = logical 0
Create multiple environment variables, and then check that they exist.
setenv(["Var1" "Var2" "Var3" "Var4"],["Val1" "Val2" "Val3" "Val4"]); isenv(["Var1" "Var2"; "Var3" "Var4"])
ans = 2×2 logical array 1 1 1 1
Remove two of the environment variables using unsetenv, and then check that they no longer exist.
unsetenv(["Var1" "Var4"]); isenv(["Var1" "Var2"; "Var3" "Var4"])
ans = 2×2 logical array 0 1 1 0
You can also remove environment variables using setenv with missing. Change the value of one environment variable and remove another.
setenv
missing
setenv(["Var2" "Var3"],["ValB" missing]); isenv(["Var1" "Var2"; "Var3" "Var4"])
ans = 2×2 logical array 0 1 0 0
Environment variable names, specified as a string scalar, character vector, string array, or cell array of character vectors.
Example: "PATH"
"PATH"
expand all
Usage notes and limitations:
Code generation does not support the use of unsetenv inside parfor loops.
parfor
Remove multiple environment variables by using unsetenv with a string array or cell array of character vectors as input.
getenv | isenv | setenv | loadenv | system | unix | dos
getenv
isenv
loadenv
system
unix
dos
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
유럽
아시아 태평양
지역별 지사에 문의