2

我想在直方图上绘制标准偏差和平均值,如下所示。

在此处输入图像描述

这是我的代码:

         filename = 'C:\Users\unique.xlsx';
        %removed duplicate entries from the file

           columnB = xlsread(filename,'B:B');



             edges = unique(columnB)



        n_elements =histc(columnB, edges)/numel(columnB);

          bar(edges,n_elements,'BarWidth',4)

           meanB=mean(columnB)   % expectation
           stdB=std(columnB)

          figure(2)
           hold on
            ylim=get(gca,'ylim')
           line([meanB meanB], ylim,'g')
              hold on
           line ([meanB+stdB meanB+stdB NaN meanB-stdB meanB-stdB] , [ylim NaN   ylim],'r')

但它给了我以下错误:

   ??? Error using ==> line
       String argument is an unknown option.

     Error in ==> read at 23
    line([meanB meanB], ylim,'g')
4

1 回答 1

4

利用

line([meanB meanB], ylim, 'Color','g');

代替

line([meanB meanB], ylim,'g');
于 2013-07-04T16:09:57.137 回答