具有命名变量的表数组(变量可包含不同类型的数据) 您所在的位置:网站首页 matlab输入变量值 具有命名变量的表数组(变量可包含不同类型的数据)

具有命名变量的表数组(变量可包含不同类型的数据)

2024-07-05 11:48| 来源: 网络整理| 查看: 265

表的自定义元数据及其变量,指定为 CustomProperties 对象。

CustomProperties 对象是可以添加到表中的自定义元数据的容器。默认情况下,CustomProperties 的属性为零。添加到 CustomProperties 的每个属性都可以包含表元数据或变量元数据。如果属性包含变量元数据,则其值必须是数组,并且数组中的元素数必须等于表变量的数量。

要将自定义元数据的属性添加到表中,请使用 addprop 函数。

要访问或修改自定义元数据,请使用语法 tableName.Properties.CustomProperties.PropertyName。在此语法中,PropertyName 是使用 addprop 添加该属性时选择的名称。

要删除属性,请使用 rmprop 函数。

注意:您只能使用 addprop 和 rmprop 为自定义元数据添加或删除属性。您不能添加或删除 tableName.Properties 对象的属性。

示例

创建一个表。

load patients T = table(LastName,Age,Height,Weight,Smoker,Systolic,Diastolic);

添加可以保存有关表及其变量的自定义元数据的属性。在此示例中,元数据是仪器的名称,true 和 false 值指示是否绘制变量,以及输出文件的名称。要添加属性,请使用 addprop 函数。

T = addprop(T,["Instrument","ToPlot","OutputFile"],["variable","variable","table"]); T.Propertiesans = TableProperties with properties: Description: '' UserData: [] DimensionNames: {'Row' 'Variables'} VariableNames: {'LastName' 'Age' 'Height' 'Weight' 'Smoker' 'Systolic' 'Diastolic'} VariableDescriptions: {} VariableUnits: {} VariableContinuity: [] RowNames: {} Custom Properties (access using t.Properties.CustomProperties.): OutputFile: [] Instrument: [] ToPlot: []

使用圆点语法将值赋给自定义元数据。将由文本值构成的数组赋给自定义元数据时,最佳做法是使用字符串数组,而不是字符向量元胞数组。如果 CustomProperties 的属性是字符向量元胞数组,则无法防止您以后将非文本值指定为元胞数组的元素。

T.Properties.CustomProperties.Instrument = ["","","height rod","scale","","blood pressure cuff","blood pressure cuff"]; T.Properties.CustomProperties.ToPlot = [false false true true false true true]; T.Properties.CustomProperties.OutputFile = 'patientData.csv'; T.Propertiesans = TableProperties with properties: Description: '' UserData: [] DimensionNames: {'Row' 'Variables'} VariableNames: {'LastName' 'Age' 'Height' 'Weight' 'Smoker' 'Systolic' 'Diastolic'} VariableDescriptions: {} VariableUnits: {} VariableContinuity: [] RowNames: {} Custom Properties (access using t.Properties.CustomProperties.): OutputFile: 'patientData.csv' Instrument: ["" "" "height rod" "scale" "" "blood pressure cuff" "blood pressure cuff"] ToPlot: [0 0 1 1 0 1 1]

从 T 中删除 OutputFile 属性。

T = rmprop(T,"OutputFile"); T.Propertiesans = TableProperties with properties: Description: '' UserData: [] DimensionNames: {'Row' 'Variables'} VariableNames: {'LastName' 'Age' 'Height' 'Weight' 'Smoker' 'Systolic' 'Diastolic'} VariableDescriptions: {} VariableUnits: {} VariableContinuity: [] RowNames: {} Custom Properties (access using t.Properties.CustomProperties.): Instrument: ["" "" "height rod" "scale" "" "blood pressure cuff" "blood pressure cuff"] ToPlot: [0 0 1 1 0 1 1]


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有