如何通过Matlab hist函数绘制下图?

时间:2019-02-14 13:21:51

标签: matlab plot bar-chart matlab-figure

如何通过matlab hist函数绘制下图?

第1组:[10、10、20];第2组:[15、10、8]。每一组包括三个算法的运行时间。

enter image description here

2 个答案:

答案 0 :(得分:4)

HIST不能解决您的问题。请尝试寻找bar函数

示例片段可能如下

g1 = [10,10,20];
g2 = [15,10,8];
algStr = sprintfc('Algorithm %d',1:3);
bar(categorical({'Group1','Group2'}),[g1;g2])
legend(algStr)

您还将需要学习如何调整图形的轴以使其与示例图形完全匹配。但是我想我会把它留给你找出。

答案 1 :(得分:2)

这不是您可以使用hist函数执行的操作,而是可以使用bar函数执行的操作:

 bar([10, 10, 20; 15, 10, 8])