propor

PURPOSE ^

PROPOR computes de proportion of volume in the region R_a contained in R_b

SYNOPSIS ^

function porcien=propor(ra,rb);

DESCRIPTION ^

 PROPOR computes de proportion of volume in the region R_a contained in R_b
 being R_a y R_b n-dimensional parallelepipeds with the same orientation.
 Paralelepipeds are defined by its boundaries in each dimension.

 USE: proporcion=propor([xma1 xMa1;xma2 xMa2;....;xman xMan],[xmb1 xMb1;xmb2 xMb2;....;xmbn xMbn]);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 % PROPOR computes de proportion of volume in the region R_a contained in R_b
0003 % being R_a y R_b n-dimensional parallelepipeds with the same orientation.
0004 % Paralelepipeds are defined by its boundaries in each dimension.
0005 %
0006 % USE: proporcion=propor([xma1 xMa1;xma2 xMa2;....;xman xMan],[xmb1 xMb1;xmb2 xMb2;....;xmbn xMbn]);
0007 
0008 function porcien=propor(ra,rb);
0009 
0010 n=size(ra);
0011 n=n(1);
0012 
0013 for i=1:n
0014     limA=ra(i,:);
0015     limB=rb(i,:);
0016     if ((limA(1)>=limB(1))&(limA(1)<=limB(2)))&((limA(2)>=limB(1))&(limA(2)<=limB(2)))
0017        l(i)=limA(2)-limA(1);
0018     elseif ((limA(1)>=limB(1))&(limA(1)<=limB(2)))&(limA(2)>=limB(2))
0019        l(i)=limB(2)-limA(1);
0020     elseif ((limA(2)>=limB(1))&(limA(2)<=limB(2)))&(limA(1)<=limB(1))
0021        l(i)=limA(2)-limB(1);
0022     elseif ((limB(1)>=limA(1))&(limB(1)<=limA(2)))&((limB(2)>=limA(1))&(limB(2)<=limA(2)))
0023        l(i)=limB(2)-limB(1);
0024     else
0025        l(i)=0;
0026     end
0027 end
0028 volint=prod(l);
0029 volA=prod(ra(:,2)-ra(:,1));
0030 porcien=volint/volA;

Generated on Fri 07-Mar-2014 13:29:20 by m2html © 2005