Home > functions > device > active_check > vb_merge_histgram_max.m

vb_merge_histgram_max

PURPOSE ^

SYNOPSIS ^

function [h,x] = vb_merge_histgram_max(h1,x1,h2,x2)

DESCRIPTION ^

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [h,x] = vb_merge_histgram_max(h1,x1,h2,x2)
0002 %
0003 % Copyright (C) 2011, ATR All Rights Reserved.
0004 % License : New BSD License(see VBMEG_LICENSE.txt)
0005 
0006 %h(n) = num of data in x(n) +- dx/2, dx =  x(2)-x(1)
0007 N1 = length(x1);
0008 N2 = length(x2);
0009 d1 = x1(2) - x1(1);
0010 d2 = x2(2) - x2(1);
0011 
0012 if max(x1)==max(x2) && N1==N2
0013     h = h1 + h2;
0014     x = x1;
0015 elseif max(x1) > max(x2)
0016     h = h1;
0017     x = x1;
0018     for n=1:N1
0019         xmax = (x1(n) + d1/2);
0020         xmin = (x1(n) - d1/2);
0021         ix = find( x2 >= xmin & x2 < xmax);
0022         if ~isempty(ix)
0023             for j=1:length(ix)
0024                 m  = ix(j); 
0025                 xx = x2(m); % mid point of h2(m)
0026                 % upper % lower bound of h2(m) in [xmin xmax] for x1(n)
0027                 xup  = min(xx + d2/2 , xmax);
0028                 xlow = max(xx - d2/2 , xmin);
0029                 % add number of h2(m) which included in [xmin xmax]
0030                 h(n) = h(n) + h2(m) * (xup - xlow)/d2;
0031             end
0032         end
0033     end
0034 else
0035     h = h2;
0036     x = x2;
0037     for n=1:N2
0038         xmax = (x2(n) + d2/2);
0039         xmin = (x2(n) - d2/2);
0040         ix = find( x1 >= xmin & x1 < xmax);
0041         if ~isempty(ix)
0042             for j=1:length(ix)
0043                 m  = ix(j); 
0044                 xx = x1(m); % mid point of h1(m)
0045                 % upper % lower bound of h1(m) in [xmin xmax] for x2(n)
0046                 xup  = min(xx + d1/2 , xmax);
0047                 xlow = max(xx - d1/2 , xmin);
0048                 % add number of h2(m) which included in [xmin xmax]
0049                 h(n) = h(n) + h1(m) * (xup - xlow)/d1;
0050             end
0051         end
0052     end
0053 end
0054

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005