2012-11-28 97 views

回答

1

我不确定这是最好的方法,因为它很难比较数据。但要显示2个直方图,请使用hold on并更改每个直方图的颜色以使其更容易。 (但也可能需要更改透明度)。我使用bar,因为hist不直接在通话本身中支持颜色。所以这很容易。

close all; 
clear all; 

x = -4:0.1:4; 
y1 = randn(200,1); 
[n,x] = hist(y1,x); 
bar(x,n,'r'); 

hold on 
y2 = randn(200,1); 
[n,x] = hist(y2,x); 
bar(x,n,'b'); 

enter image description here

0

在纳赛尔M.阿巴西的代码中使用bar,使用stem,看看有没有什么帮助的这一翻译。