fork download
  1. A = [1 2 3;4 5 6;7 8 9];
  2. tic;
  3. B1 = repmat( A, [1 1 10] );
  4. toc
  5. tic;
  6. B2 = A(:,:,ones(1,10));
  7. toc
  8. tic
  9. B3 = bsxfun(@times, A, ones(1,1,10) );
  10. toc
Success #stdin #stdout 0.18s 65056KB
stdin
Standard input is empty
stdout
Elapsed time is 0.0203459 seconds.
Elapsed time is 0.00014395 seconds.
Elapsed time is 0.0149179 seconds.