【发布时间】:2015-01-12 11:22:30
【问题描述】:
matlab 中的 hist 函数在纵轴上绘制数据点的频率。如果我想将频率乘以一个数字该怎么办。
例如,如果一个对象在整个数据记录过程中指向北方 10 次,并且每次都在北方位置停留 5 秒。与其让 hist plot 显示该对象指向 North 10 次,我希望它显示它指向 North 总共 50 秒。
【问题讨论】:
matlab 中的 hist 函数在纵轴上绘制数据点的频率。如果我想将频率乘以一个数字该怎么办。
例如,如果一个对象在整个数据记录过程中指向北方 10 次,并且每次都在北方位置停留 5 秒。与其让 hist plot 显示该对象指向 North 10 次,我希望它显示它指向 North 总共 50 秒。
【问题讨论】:
您可以使用 histc(或 2014b 中的 histcounts)函数在不绘制数据的情况下进行 bin 计数,然后使用条形图绘制。
directions = rand(1000, 1)*360;
% note that histc counts the last element as exactly equal, so I pad
edges = [0:5:360, inf];
counts = histc(directions, edges);
multiplier = 5;
bar(edges(1:end-1)*multiplier, counts(1:end-1))
【讨论】: