Home > melodyRecognition > histPlot.m

histPlot

PURPOSE ^

PLOTHIST Histogram plot of CBMR test results

SYNOPSIS ^

function plothist(rank)

DESCRIPTION ^

 PLOTHIST Histogram plot of CBMR test results

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function plothist(rank)
0002 % PLOTHIST Histogram plot of CBMR test results
0003 
0004 [sorted_element, element_count] = countele(rank);
0005 
0006 %bar(sorted_element, element_count);
0007 
0008 a = 1:length(sorted_element);
0009 bar(a, element_count);
0010 set(gca, 'xticklabel', []);
0011 
0012 axis([0 inf 0 inf]);
0013 grid;
0014 xlabel('Ranking');  ylabel('Histogram'); title('Ranking Histogram')
0015 
0016 
0017 % Plotting
0018 for k = 1:length(sorted_element),
0019     text(k, -1, num2str(sorted_element(k)), 'color', 'black');
0020 end
0021 h = findobj(gcf, 'type', 'text');
0022 set(h, 'rot', 90, 'fontsize', 10, 'hori', 'right');
0023 
0024 
0025 % ====== Count elements of a vector
0026 function [sorted_element, element_count] = countele(in)
0027 %COUNTELE Count elements in a vector.
0028 %    Type "countele" for a self demo.
0029 
0030 %    Roger Jang, 3-27-1997
0031 
0032 if nargin == 0,
0033     in = [0.4 0.3 0.3 0.2 0.1 0.4 0.4 0.3 0.4];
0034     fprintf('The input vector "in" is\n');
0035     for i = 1:length(in),
0036         fprintf('%g ', in(i));
0037     end
0038     fprintf('\n\n"[sorted_element, element_count] = countele(in)" produces the following output:\n');
0039     [sorted_element, element_count] = countele(in)
0040     return;
0041 end
0042 
0043 [m,n] = size(in);
0044 in1 = sort(in(:)');
0045 in1 = [in1 in1(length(in1))+1];
0046 index = find(diff(in1) ~= 0);
0047 sorted_element = in1(index);
0048 element_count = diff([0, index]);
0049 if n == 1,
0050     sorted_element = sorted_element';
0051     element_count = element_count';
0052 end

Generated on Tue 01-Jun-2010 09:49:37 by m2html © 2003