Home > GLMdenoise > utilities > calccodcell.m

calccodcell

PURPOSE ^

function f = calccodcell(x,y,dim)

SYNOPSIS ^

function f = calccodcell(x,y,dim)

DESCRIPTION ^

 function f = calccodcell(x,y,dim)

 <x>,<y> are cell vectors of matrices.  the cell vectors should
   have the same dimensions and their matrix elements should have
   the same dimensions too.
 <dim> is the dimension of interest

 simply return calccod(catcell(dim,x),catcell(dim,y),dim,0,0) but 
 do so in a way that doesn't cause too much memory usage.
 note that NaNs must not exist in <x> nor <y>!
 also, note that this function has less functionality than the 
 original calccod.m.

 example:
 a = calccod([1 2 3; 4 5 6],[2 3 4; 5 6 7],1,0,0);
 a2 = calccodcell({[1 2 3] [4 5 6]},{[2 3 4] [5 6 7]},1);
 allzero(a-a2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function f = calccodcell(x,y,dim)
0002 
0003 % function f = calccodcell(x,y,dim)
0004 %
0005 % <x>,<y> are cell vectors of matrices.  the cell vectors should
0006 %   have the same dimensions and their matrix elements should have
0007 %   the same dimensions too.
0008 % <dim> is the dimension of interest
0009 %
0010 % simply return calccod(catcell(dim,x),catcell(dim,y),dim,0,0) but
0011 % do so in a way that doesn't cause too much memory usage.
0012 % note that NaNs must not exist in <x> nor <y>!
0013 % also, note that this function has less functionality than the
0014 % original calccod.m.
0015 %
0016 % example:
0017 % a = calccod([1 2 3; 4 5 6],[2 3 4; 5 6 7],1,0,0);
0018 % a2 = calccodcell({[1 2 3] [4 5 6]},{[2 3 4] [5 6 7]},1);
0019 % allzero(a-a2)
0020 
0021 numer = cellfun(@(a,b) sum((a-b).^2,dim),x,y,'UniformOutput',0);
0022 denom = cellfun(@(a)   sum(a.^2,dim),      y,'UniformOutput',0);
0023 f = 100*(1 - zerodiv(sum(catcell(dim,numer),dim),sum(catcell(dim,denom),dim),NaN,0));

Generated on Fri 01-Aug-2014 12:03:17 by m2html © 2005