what's the fastest way to subtract two cell arrays in matlab -


pretend have 2 cell arrays , b, each element in cells n*m matrix, example :
a={ [2 3;4 5] [1 5;7 8]} , b={ [1 2;4 5] [7 9;10 1]} both cells each element 2*2 matrix.

now can subtract cell arrays element-wise this:

c=cellfun(@minus,a,b,'uniformoutput',false); 

this result in c={[1 1;0 0] [-6 -4;-3 7]}.

now fastest way ? or there faster approach ?

consider cells large number of matrices each matrix small.

as mentioned lot depends on data, in example fastest way nested loop:

a={ [2 3;4 5] [1 5;7 8]}; b={ [1 2;4 5] [7 9;10 1]}; tic c=cellfun(@minus,a,b,'uniformoutput',false); toc tic s = size(a); ii=1:s(1)   jj=1:s(2)     d{ii,jj} = a{ii,jj}-b{ii,jj};   end end toc isequal ( c, d ) 

output:

elapsed time 0.001420 seconds. elapsed time 0.000017 seconds.  ans =       1 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -