发布时间:2025-12-09 13:52:53 浏览次数:4
生成数据aa,然后利用histogram对h进行统计,自动给h进行分列。
1.形式一:histogram(aa)
aa = randn(1000,1);h = histogram(aa);
2. 形式二:histogram(aa,nbins),指定柱状的数量:
hh = histogram(aa,10);
3. 形式三:histogram(aa,[-10:0.5:10]),控制横坐标的范围;
hhh = histogram(aa,[-10:0.5:10]);
4. 两个直方图叠加
x = randn(2000,1); y = 1 + randn(5000,1); h1 = histogram(x); hold on; h2 = histogram(y);
5. 如果想纵坐标显示频率而非频数;
h = histogram(aa);h.Normalization = 'probability';或者直接
histogram(aa,'Normalization','probability')6.调整每个柱的宽度(区间长度)
h.BinWidth = 0.1;cite:
cdf曲线:直接
costCdf = cdfplot(cost);即画出cost的CDF曲线。