MATLAB 帮助中心
删除结构体中的字段
s = rmfield(s,field)
s = rmfield(s,field) 从结构体数组 s 中删除指定的一个或多个字段。使用字符向量元胞数组或字符串数组指定多个字段。s 的维度保持不变。
s
field
示例
全部折叠
定义一个包含名为 a、b 和 c 的字段的标量结构体。
a
b
c
s.a = 1; s.b = 2; s.c = 3;
删除字段 b。
field = 'b'; s = rmfield(s,field)
s = struct with fields: a: 1 c: 3
定义一个包含 first、second、third 和 fourth 字段的标量结构体。
first
second
third
fourth
S.first = 1; S.second = 2; S.third = 3; S.fourth = 4;
删除字段 first 和 fourth。
fields = {'first','fourth'}; S = rmfield(S,fields)
S = struct with fields: second: 2 third: 3
输入结构体,指定为结构体数组。
数据类型: struct
struct
字段名称,指定为字符数组、字符向量元胞数组或字符串数组。
示例: 'f1'
'f1'
示例: {'f1';'f2'}
{'f1';'f2'}
数据类型: char | cell | string
char
cell
string
全部展开
backgroundPool
ThreadPool
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
此函数完全支持分布式数组。有关详细信息,请参阅使用分布式数组运行 MATLAB 函数 (Parallel Computing Toolbox)。
在 R2006a 之前推出
fieldnames | isfield | orderfields | setfield
fieldnames
isfield
orderfields
setfield
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 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处