% % An extension of example 9.1 % This illustrates the 1-D histogram using relative frequency and frequency. % % Written by: % -- % John L. Weatherwax 2005-08-14 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; drawnow; rehash; clc; load forearm; % The 'hist' function can return the % bin centers and frequencies. % Use the default number of bins - 10. %nBins = 5; nBins = 50; %nBins = 10; [n, x] = hist(forearm,nBins); % Plot and use the argument of width = 1 % to get bars that touch. figure; bar(x,n,1,'w'); title('Frequency Histogram - Forearm Data') xlabel('Measurement') ylabel('Frequency') % Now create a relative frequency histogram. % Divide each box by the total number of points. figure; bar (x,n/140,1,'w') title('Relative Frequency Histogram - Forearm Data') xlabel('Measurement') ylabel('Relative Frequency')