Find columns which have all constant values

版本 1.0.0 (1.2 KB) 作者: Chenghao
This function works for NaN, Missing, numeric, string, boolean, etc
23.0 次下载
更新时间 2018/11/21

查看许可证

Generate test data:

clear;

n = 10;
c1 = repmat(3,[n,1]); % n times of value 3
c2 = rand(n,1); % n values
c3 = repmat(NaN, [n,1]);
c4 = c3;
c4(4) = 2;
c5 = repmat(missing,[n,1]);
c6 = cellstr(repmat('test',n,1));
c7 = c6;
c7{7} = 'hello';
c8 = repmat(false,[n,1]);
c9 = c8;
c9(9) = true;

T = table(c1,c2,c3,c4,c5,c6,c7,c8,c9);

cellData = table2cell(T);
constantColumnIndex = constantColumnExtraction(cellData);
constantColumnNames = T.Properties.VariableNames(constantColumnIndex);

引用格式

Chenghao (2024). Find columns which have all constant values (https://www.mathworks.com/matlabcentral/fileexchange/69489-find-columns-which-have-all-constant-values), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2018b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Characters and Strings 的更多信息
标签 添加标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0