Home > vbmeg > functions > device > active_check > vb_merge_histgram.m

vb_merge_histgram

PURPOSE ^

SYNOPSIS ^

function [h,x] = vb_merge_histgram(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(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 h = h1;
0013 x = x1;
0014 
0015 for n=1:N1
0016     xmax = (x1(n) + d1/2);
0017     xmin = (x1(n) - d1/2);
0018     ix = find( x2 >= xmin & x2 < xmax);
0019     if ~isempty(ix)
0020         for j=1:length(ix)
0021             m  = ix(j); 
0022             xx = x2(m); % mid point of h2(m)
0023             % upper % lower bound of h2(m) in [xmin xmax] for x1(n)
0024             xup  = min(xx + d2/2 , xmax);
0025             xlow = max(xx - d2/2 , xmin);
0026             % add number of h2(m) which included in [xmin xmax]
0027             h(n) = h(n) + h2(m) * (xup - xlow)/d2;
0028         end
0029     end
0030 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005