fork download
  1. clear all;clc
  2.  
  3. N = 15;
  4. A = rand(N,N,N,N);
  5. for ii = 1:N
  6. for jj = 1:N
  7. B{ii,jj} = rand(N,N,N,N);
  8. end
  9. end
  10.  
  11. tic
  12. rB = reshape(cat(5,B{:}),numel(A),[]).';
  13. out1 = reshape(rB*A(:),size(B));
  14. toc
  15.  
  16. tic
  17. rB = cellfun( @(x) x(:).', B, 'uni', 0 ); %'
  18. rB = vertcat(rB{:});
  19. dummy = reshape(rB * A(:), size(B) );
  20. toc
Success #stdin #stdout 2.74s 64960KB
stdin
Standard input is empty
stdout
Elapsed time is 0.333833 seconds.
Elapsed time is 1.57362 seconds.