function [ res ] = plotTruthFAHistograms( data1, data2, nBins, varargin ) % % Written by: % -- % John L. Weatherwax 2006-06-29 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- figure; % Handle all the cases when data1 or data2 is empty: if( isempty( data1 ) & isempty( data2 ) ) % Do nothing. elseif( isempty( data1 ) ) [ n, x ] = hist( data2, nBins ); bar( x, n, 'hist', 'r' ); elseif( isempty( data2 ) ) [ n, x ] = hist( data1, nBins ); bar( x, n, 'hist', 'g' ); else % Form a matrix with the data: amtOfData = max( length(data1), length(data2) ); histData = zeros( amtOfData, 2 ); histData(:,1) = [ data1(:).' NaN*ones( 1, amtOfData-length(data1) ) ].'; histData(:,2) = [ data2(:).' NaN*ones( 1, amtOfData-length(data2) ) ].'; % Plot the data: [ n, x ] = hist( histData, nBins ); bar( x, n(:,1), 'hist', 'g' ); hold on; bar( x, n(:,2), 'hist', 'r' ); hold off; axis tight; end xlabel( 'data value' ); ylabel( 'frequency' ); res = gcf;