使用Matlab的histogram()同时绘制两组数据

Using Matlab's histogram() to simultaneously plot two sets of data

我有一个矩阵 A,其中包含两组数据的两列。我想将这些绘制在同一个直方图上,对代表 class 间隔的条使用不同的颜色。我可以使用 hist(A) 来做到这一点,在这种情况下,矩阵中的每一列都被视为一组不同的数据。我想改用 histogram() ,并为垃圾箱定义边缘。我该怎么做?

答案比我想象的要简单:

histogram(A(:,1))
hold on
histogram(A(:,2))

这会自动使条形透明,因此都可以看到。