主要内容

rmprop

从表或时间表中删除自定义属性

说明

T2 = rmprop(T1,propertyNames) 从表或时间表中删除包含自定义元数据的属性。输入参量 propertyNames 指定属性的名称。

示例

示例

全部折叠

将包含自定义元数据的属性添加到表中。然后删除一些属性。

首先,将湿度和空气质量的测量值读入表中。

T = readtable("indoors.csv")
T=60×3 table
           Time            Humidity    AirQuality
    ___________________    ________    __________

    2015-11-15 00:00:24       36           80    
    2015-11-15 01:13:35       36           80    
    2015-11-15 02:26:47       37           79    
    2015-11-15 03:39:59       37           82    
    2015-11-15 04:53:11       36           80    
    2015-11-15 06:06:23       36           80    
    2015-11-15 07:19:35       36           80    
    2015-11-15 08:32:47       37           80    
    2015-11-15 09:45:59       37           79    
    2015-11-15 10:59:11       36           80    
    2015-11-15 12:12:23       37           80    
    2015-11-15 13:25:35       37           79    
    2015-11-15 14:38:46       36           83    
    2015-11-15 15:51:58       37           80    
    2015-11-15 17:05:10       36           80    
    2015-11-15 18:18:22       37           80    
      ⋮

使用 addprop 函数为自定义元数据添加属性。然后为这些属性指定元数据。

T = addprop(T,["Instrument" "Precision" "SourceFile"],["variable" "variable" "table"]);
T.Properties.CustomProperties.Instrument = ["clock" "hygrometer" "air quality meter"];
T.Properties.CustomProperties.Precision = [NaN 0.5 0.1];
T.Properties
ans = 
  TableProperties with properties:

             Description: ''
                UserData: []
          DimensionNames: {'Row'  'Variables'}
           VariableNames: {'Time'  'Humidity'  'AirQuality'}
           VariableTypes: ["datetime"    "double"    "double"]
    VariableDescriptions: {}
           VariableUnits: {}
      VariableContinuity: []
                RowNames: {}

   Custom Properties (access using t.Properties.CustomProperties.<name>):
              SourceFile: []
              Instrument: ["clock"    "hygrometer"    "air quality meter"]
               Precision: [NaN 0.5000 0.1000]

要删除属性,请使用 rmprop 函数。您只能删除您之前使用 addprop 添加的自定义属性。您不能删除 T.Properties 中的其他属性,但可以删除它们包含的值。

T.Properties.CustomProperties 中删除 InstrumentSourceFile 属性。

T = rmprop(T,["Instrument" "SourceFile"]);
T.Properties
ans = 
  TableProperties with properties:

             Description: ''
                UserData: []
          DimensionNames: {'Row'  'Variables'}
           VariableNames: {'Time'  'Humidity'  'AirQuality'}
           VariableTypes: ["datetime"    "double"    "double"]
    VariableDescriptions: {}
           VariableUnits: {}
      VariableContinuity: []
                RowNames: {}

   Custom Properties (access using t.Properties.CustomProperties.<name>):
               Precision: [NaN 0.5000 0.1000]

输入参数

全部折叠

输入表,指定为表或时间表。

自定义属性的名称,指定为字符串数组、字符向量、字符向量元胞数组或 pattern 标量。

输出参量

全部折叠

删除了属性的输出表,以表或时间表形式返回。

扩展功能

全部展开

版本历史记录

在 R2018b 中推出