MATLAB 帮助中心
Names of variables in workspace
Since R2025a
s = variableNames(w)
s = variableNames(w,var1,...,varN)
s = variableNames(w) returns the names of the variables contained in the specified workspace object.
s
w
example
s = variableNames(w,var1,...,varN) returns the names of the specified variables. If any of the specified variables do not exist in w, they are omitted from the output.
var1,...,varN
collapse all
Create a set of variables in the base workspace.
a = 1; b = true; c = "Hello, World";
Create a workspace object for the base workspace. Then return the variable names using the workspace object.
w = matlab.lang.Workspace.baseWorkspace; s = variableNames(w)
s = 3×1 string "a" "b" "c"
Create a workspace object for the base workspace. Then return the variable names a and b.
a
b
w = matlab.lang.Workspace.baseWorkspace; s = variableNames(w,"a","b")
s = 2×1 string "a" "b"
matlab.lang.Workspace
Workspace, specified as a matlab.lang.Workspace object.
Variables, specified as string scalars or character vectors.
Names of the variables, returned as a string array.
Introduced in R2025a
matlab.lang.Workspace.baseWorkspace
matlab.lang.Workspace.currentWorkspace
matlab.lang.Workspace.globalWorkspace
variables
evaluateAndCapture
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 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处