用matlab做直方图
时间: 2023-07-20 20:37:46 浏览: 135
好的,以下是使用MATLAB绘制直方图的示例代码:
```matlab
% 样本数据
data = [93, 75, 83, 93, 91, 85, 84, 82, 77, 76, 77, 95, 94, 89, 91, 88, 86, 83, 96, 81, 79, 97, 78, 75, 67, 69, 68, 84, 83, 81, 75, 66, 85, 70, 94, 84, 83, 82, 80, 78, 74, 73, 76, 70, 86, 76, 90, 89, 71, 66, 86, 73, 80, 94, 79, 78, 77, 63, 53, 55];
% 设置直方图的边界和宽度
edges = 50:5:100;
width = 4;
% 绘制直方图
histogram(data, edges, 'FaceColor', 'blue', 'EdgeColor', 'white', 'BinWidth', width);
% 设置x轴和y轴的标签
xlabel('Score');
ylabel('Frequency');
% 设置图形的标题
title('Score Distribution');
% 显示网格
grid on;
```
这段代码将会生成一个直方图,横轴表示成绩,纵轴表示成绩出现的频次。
阅读全文
相关推荐















