赞
踩
R = rmmissing(A)
消除数据中的NaN
%向量
A = [1 3 NaN 6 NaN];
R = rmmissing(A)
%矩阵
A = table(categorical({'';'F';'M'}),[45;32;NaN],{'';'CA';'MA'},[6051;7234;NaN],...
'VariableNames',{'Gender' 'Age' 'State' 'ID'})
R = rmmissing(A)
R = rmmissing(A,'DataVariables',{'Age','ID'})
C = unique(A)
消除数据中的重复值
A = [5 5 NaN NaN];
C = unique(A)
...=[]
去除数据所在行
dataAssembly(dataAssembly.('变量名') < 50, :) = []; %行delete/缩减
% 去除离群点
%data为timetable type
TR1 = timerange("2002-01-29 1:00:00", "2002-03-29 2:30:00"); %去除的时间段
data(TR1, :) = []; %行delete/缩减
rho = corr(dataAssembly.Variables, 'Type', 'Pearson');
相关系数计算
figure; h = heatmap(sensorNames, sensorNames, rho, 'Colormap', jet);
%Colormap颜色柱并赋色
绘图-热图
%方式一
label_name = {'N1','N2','N3','N4','N5','N6','N7','N8','N9','N10','N11','N12','N13'};
xlabel_name = label_name;
hot_figure = heatmap(xlabel_name,ylabel_name,X,'FontSize',10);
%x轴name,y轴name,数值X(matrix)
%方式二
load patients
tbl = table(LastName,Age,Gender,SelfAssessedHealthStatus,...
Smoker,Weight,Location);
h = heatmap(tbl,'Smoker','SelfAssessedHealthStatus');%all值表,x轴值(vector),y轴值(vector)
y = rms(x,dim)
[B,I] = sort(___)
B排序后的matrix, B中元素在原matrix中的旧id
D = pdist(X,Distance) 使用 Distance 指定的方法返回距离。
D = pdist(X) %向量结果
Z = squareform(D) %矩阵化
D = pdist2(X,Y,Distance) 使用 Distance 指定的度量返回 X 和 Y 中每对观测值之间的距离。
若X向量1m,Y矩阵nm。则=n*1.
remove向量中NaN
% Remove missing observations indicated by NaN’s and check sample size.
x = x(~isnan(x));
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。