Count strings occurrences and plot histogram

后端 未结 4 497
陌清茗
陌清茗 2021-01-18 05:09

Is there any straightforward way to create a histogram from a cell array like the one below? The spacing between the consecutive bars should be exactly the same and the labe

4条回答
  •  [愿得一人]
    2021-01-18 05:34

    You can also use the histogram function as follows:

    [C,~,ic] = unique(A);
    
    fig1 = figure;
    axes1 = axes('Parent',fig1,'XTickLabel',C,'XTick',1:length(C));
    hold(axes1,'on');
    
    histogram(ic)
    

提交回复
热议问题