clear all;
load patients
% 行名,维度名称
% T = table(Age,Height,Weight,'RowName',...
% LastName,'DimensionNames',["PatientName","PatientData"])
T = table(Age,Height,Weight,'RowName',...
LastName)
% 表的属性
T.Properties
%
% T.PatientName
% T.PatientData
%表格总结
T_sum = summary(T)
T_sum.Age
% table 的输入元素:
% 1.var :输入变量 (数组)
% 2.sz :预分配的空间大小 (二元素数值向量)
% 3.varTypes :预分配的变量名类型 (字符向量元胞数组 | 字符串数组)
% 4.VariableNames :变量名称
% 5.RowNames :行名称 字符向量元胞数组 | 字符串数组
% 6.DimensionNames :维度名称 二元素字符向量元胞数组 | 二元素字符串数组
% table 的属性
% 1. DimensionNames — 维度名称 % {'Row','Variables'} (默认) | 二元素字符向量元胞数组 | 二元素字符串数组
T.Properties.DimensionNames
T.Row(1:5)
T.Variables
T.Properties.DimensionNames = ["Patient","Data"];
T.Properties
% 2. RowNames — 行名称 {} (默认) | 字符向量元胞数组 | 字符串数组
% T.Properties.RowNames = string(LastName);
head(T,5)
T(["Smith","Brown"],:)
% 3. Description — 表描述 '' (默认) | 字符向量 | 字符串标量
load patients
T = table(LastName,Age,Height,Weight);
T.LastName = string(T.LastName);
T.Properties.Description = "Simulated patient data";
summary(T)
% 4. UserData — 其他表信息
% [] (默认) | 数组
load patients
T = table(LastName,Age,Height,Weight,Smoker,Systolic,Diastolic);
formula = @(x) x.^2;
T.Properties.UserData = formula;
T.Properties
% 变量元数据
% 1.VariableNames — 变量名称 字符向量元胞数组 | 字符串数组
T = table(["Smith";"Nguyen";"Williams";"Fernandez";"Brown"],[38;43;38;40;49], ...
[71;69;64;67;64],[176;163;131;133;119])
T.Properties.VariableNames = ["LastName","Age","Height","Weight"]
T.Age
T.Age(1) = 53
% 2.VariableDescriptions — 变量描述 {} (默认) | 字符向量元胞数组 | 字符串数组
load patients
T = table(LastName,Age,Height,Weight,Smoker,Systolic,Diastolic);
T.LastName = string(T.LastName);
T.Properties.VariableDescriptions = ["","","","", ...
"Has the patient ever been a smoker", ...
"Systolic Pressure","Diastolic Pressure"];
summary(T)
% 3.VariableUnits — 变量单位 {} (默认) | 字符向量元胞数组 | 字符串数组
load patients
T = table(LastName,Age,Height,Weight,Smoker,Systolic,Diastolic);
T.LastName = string(T.LastName);
T.Properties.VariableUnits = ["","Yrs","In","Lbs","","mm Hg","mm Hg"];
summary(T)
% 4.VariableContinuity — 状态为连续或离散变量 [] (默认) | 字符向量元胞数组 | 字符串数组
% 5.自定义元数据
load patients
T = table(LastName,Age,Height,Weight,Smoker,Systolic,Diastolic);
T = addprop(T,["Instrument","ToPlot","OutputFile"],["variable","variable","table"]);
T.Properties
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.Properties
T = rmprop(T,"OutputFile");
T.Properties
%添加数据 T2(1,:) = {75,datetime('now'),"S1"};
%使用行名称访问数据 T('Lee',:)
%T({'Lee','Brown'},:)
% T.('29-May-2019 Blood Pressure Reading') = BloodPressure
05-01
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交