[英]How to connect pick points of a histogram by a curve in Matlab?
I am beginner in Matlab. 我是Matlab的初学者。 I have a histogram of a set of data I need to do 2 things. 我有一组数据的直方图,我需要做两件事。 1) I need the vertical axes to be normalized. 1)我需要对垂直轴进行归一化。 2) To curve a fit that passes through all the pick points of my Histogram bars. 2)弯曲穿过直方图条的所有选取点的拟合。
Thank you 谢谢
You can do it along these lines: 您可以按照以下方式进行操作:
data = randn(1,1000); %// example data
num_bars = 15; %// specify number of bars
[n x] = hist(data,num_bars); %// use two-output version of hist to get values
n_normalized = n/numel(data)/(x(2)-x(1)); %// normalize to unit area
bar(x, n_normalized, 1); %// plot histogram (with unit-width bars)
hold on
plot(x, n_normalized, 'r'); %// plot line, in red (or change color)
For (1) try axis([xmin xmax ymin ymax])
对于(1),请尝试axis([xmin xmax ymin ymax])
For (2) try first drawing the histogram, then call hold on
, then use the plot
command. 对于(2),请先尝试绘制直方图,然后调用hold on
,然后使用plot
命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.