【问题标题】:Histogram of a categorical table in MatlabMatlab中分类表的直方图
【发布时间】:2014-10-25 15:31:40
【问题描述】:

我的表 tNonNumeric 仅包含分类值。我试图找到独特的元素以及它们在我的表格中出现的次数。不是我的实际数据,但可以使用以下数据:

LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
FirstName = {'Amanda' ;'Brenda';'Carl'; 'Denis'; 'Ethan'};
Something = {'String1' ;'String2';'String2'; 'String1'; 'String5'};
Weight = [176;163;131;133;119];
FavoriteColor = {'blue' ;'red' ;'yellow'; 'orange' ;'colorblind' };
T = table(Age,FirstName,Weight,FavoriteColor,Something,'RowNames',LastName)
T.FavoriteColor= categorical(T.FavoriteColor);
T.Something= categorical(T.Something); 

那么如何将直方图应用于分类值?

【问题讨论】:

    标签: matlab count unique histogram


    【解决方案1】:

    函数直方图不适用于分类数据,但 hist 可以:

    hist(T.Something)
    

    【讨论】:

    • 字符串值怎么样?
    猜你喜欢
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 2013-01-17
    • 2013-07-25
    • 1970-01-01
    • 2012-11-06
    • 1970-01-01
    • 2013-01-25
    相关资源
    最近更新 更多