This is a static copy of a profile report

Home

num2cell (Calls: 72, Time: 0.003 s)
Generated 16-Jul-2020 17:09:32 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/datatypes/num2cell.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...b.modifyUnitsForPrint/getObjWithUnitsnested function60
...ifyUnitsForPrint/updatePixelFontUnitsnested function12
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
32
c = cell(size(a));
720.001 s29.0%
31
if nargin==1
720.000 s13.6%
36
return
720.000 s12.6%
33
for i=1:numel(a)
720.000 s4.1%
30
narginchk(1,2);
720.000 s0.9%
All other lines  0.001 s39.8%
Totals  0.003 s100% 
Children (called functions)
No children
Code Analyzer results
Line numberMessage
61Extra comma is unnecessary in FOR statement before newline.
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 run5
Code lines that did not run17
Coverage (did run/can run)22.73 %
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 

< 0.001 
     72 
  30
narginchk(1,2); 
< 0.001 
     72 
  31
if nargin==1 
< 0.001 
     72 
  32
    c = cell(size(a)); 
< 0.001 
     72 
  33
    for i=1:numel(a) 
  34 
        c{i} = a(i);
  35 
    end 
< 0.001 
     72 
  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

Other subfunctions in this file are not included in this listing.