Draw a histogram by giving me matlab codes using following 12 pairs of data diameter = 0995 0995-0996 0996-0997 0997-0998 0998-0999 0999-1000 1000-1001 1001-1002 1002-1003 1003-1004 1004-1005 1005 and
diameter = [0.995, 0.995, 0.996, 0.997, 0.998, 0.999, 1.000, 1.001, 1.002, 1.003, 1.004, 1.005, 1.005]; freq = [1, 0, 8, 9, 15, 25, 22, 9, 7, 3, 1, 0];
figure; histogram(diameter, 'BinWidth', 0.001, 'BinLimits', [0.995, 1.005], 'FaceColor', 'b', 'FaceAlpha', 0.5); xlabel('Diameter'); ylabel('Frequency'); title('Histogram of Diameter');
% Add frequency counts to the bars hold on; for i = 1:length(freq) text(diameter(i)+(0.0005/2), freq(i)+1, num2str(freq(i)), 'HorizontalAlignment', 'center'); end hold off
原文地址: https://www.cveoy.top/t/topic/eGdP 著作权归作者所有。请勿转载和采集!