This is a static copy of a profile report

Home

num2cell (3 calls, 0.020 sec)
Generated 14-Nov-2016 07:47:22 using cpu time.
function in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/datatypes/num2cell.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...intPath>LocalUpdateOpenGLLineWidthsubfunction3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
35
end 
67440.020 s100.0%
36
return
30 s0%
34
c{i} = a(i);
67440 s0%
33
for i=1:numel(a)
30 s0%
32
c = cell(size(a));
30 s0%
All other lines  0 s0%
Totals  0.020 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function63
Non-code lines (comments, blank lines)41
Code lines (lines that can run)22
Code lines that did run7
Code lines that did not run15
Coverage (did run/can run)31.82 %
Function listing
time 
calls 
 line
   1 
function c = num2cell(a,dims)
   2 
%NUM2CELL Convert numeric array into cell array.
   3 
%   C = NUM2CELL(A) converts numeric array A into cell array C by placing
   4 
%   each element of A into a separate cell in C. The output array has the
   5 
%   same size and dimensions as the input array. Each cell in C contains
   6 
%   the same numeric value as its respective element in A.
   7 
%
   8 
%   C = NUM2CELL(A, DIM) converts numeric array A into a cell array of
   9 
%   numeric vectors, the dimensions of which depend on the value of the DIM
  10 
%   argument. Return value C contains NUMEL(A)/SIZE(A,DIM) vectors, each of
  11 
%   length SIZE(A, DIM). The DIM input must be an integer with a value from
  12 
%   NDIMS(A) to 1.
  13 
%
  14 
%   C = NUM2CELL(A, [DIM1, DIM2, ...]) converts numeric array A into a cell
  15 
%   array of numeric arrays, the dimensions of which depend on the values
  16 
%   of arguments [DIM1, DIM2, ...]. Given the variables X and Y, where
  17 
%   X=SIZE(A,DIM1) and Y=SIZE(A,DIM2), return value C contains
  18 
%   NUMEL(A)/PROD(X,Y,...) arrays, each of size X-by-Y-by-.... All DIMn
  19 
%   inputs must be an integer with a value from NDIMS(A) to 1.
  20 
%
  21 
%   NUM2CELL works for all array types.
  22 
%
  23 
%   Use CELL2MAT or CAT(DIM,C{:}) to convert back.
  24 
%
  25 
%   See also MAT2CELL, CELL2MAT
  26 

  27 
%   Clay M. Thompson 3-15-94
  28 
%   Copyright 1984-2012 The MathWorks, Inc.
  29 

      3 
  30 
narginchk(1,2); 
      3 
  31 
if nargin==1 
      3 
  32 
    c = cell(size(a)); 
      3 
  33 
    for i=1:numel(a) 
   6744 
  34 
        c{i} = a(i); 
  0.02 
   6744 
  35 
    end  
      3 
  36 
    return 
  37 
end
  38 

  39 
% Size of input array
  40 
siz = [size(a),ones(1,max(dims)-ndims(a))];
  41 

  42 
% Create remaining dimensions vector
  43 
rdims = 1:max(ndims(a),max(dims));
  44 
rdims(dims) = []; % Remaining dims
  45 

  46 
% Size of extracted subarray
  47 
bsize(sort(dims)) = siz(dims);
  48 
bsize(rdims) = 1; % Set remaining dimensions to 1
  49 

  50 
% Size of output cell
  51 
csize = siz;
  52 
csize(dims) = 1; % Set selected dimensions to 1
  53 
c = cell(csize);
  54 

  55 
% Permute A so that requested dims are the first few dimensions
  56 
a = permute(a,[dims rdims]); 
  57 

  58 
% Make offset and index into a
  59 
offset = prod(bsize);
  60 
ndx = 1:prod(bsize);
  61 
for i=0:prod(csize)-1,
  62 
  c{i+1} = reshape(a(ndx+i*offset),bsize);
  63 
end