This is a static copy of a profile report

Home

Function details for ndgridThis is a static copy of a profile report

Home

ndgrid (Calls: 30, Time: 0.171 s)
Generated 03-Jul-2019 19:57:15 using performance time.
function in file C:\Program Files\MATLAB\R2019a\toolbox\matlab\elmat\ndgrid.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ff_wkz_vf_vecfunction30
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
64
varargout{2} = repmat(y,size(x...
300.083 s48.8%
63
varargout{1} = repmat(x,size(y...
300.083 s48.7%
56
siz = cellfun(@numel,varargin)...
300.002 s1.0%
75
end
300.000 s0.2%
42
if nargin==0 || (nargin > 1...
300.000 s0.2%
All other lines  0.002 s1.1%
Totals  0.171 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function75
Non-code lines (comments, blank lines)42
Code lines (lines that can run)33
Code lines that did run14
Code lines that did not run19
Coverage (did run/can run)42.42 %
Function listing
time 
Calls 
 line
   1 
function varargout = ndgrid(varargin)
   2 
%NDGRID Rectangular grid in N-D space
   3 
%   [X1,X2,X3,...] = NDGRID(x1gv,x2gv,x3gv,...) replicates the grid vectors 
   4 
%   x1gv,x2gv,x3gv,...  to produce the coordinates of a rectangular grid 
   5 
%   (X1,X2,X3,...).  The i-th dimension of the output array Xi are copies
   6 
%   of elements of the grid vector xigv. For example, the grid vector x1gv 
   7 
%   forms the rows of X1, the grid vector x2gv forms the columns of X2 etc. 
   8 
%
   9 
%   [X1,X2,...] = NDGRID(xgv) is equivalent to [X1,X2,...] = NDGRID(xgv,xgv,...).
  10 
%   The dimension of the output is determined by the number of output
  11 
%   arguments. X1 = NDGRID(xgv) degenerates to produce a 1-D grid represented
  12 
%   by a 1-D array.
  13 
%
  14 
%   The coordinate arrays are typically used for the evaluation of functions 
  15 
%   of several variables and for surface and volumetric plots.
  16 
%
  17 
%   NDGRID and MESHGRID are similar, though NDGRID supports 1-D to N-D while 
  18 
%   MESHGRID is restricted to 2-D and 3-D. In 2-D and 3-D the coordinates 
  19 
%   output by each function are the same, the difference is the shape of the 
  20 
%   output arrays. For grid vectors x1gv, x2gv and x3gv of length M, N and P 
  21 
%   respectively, NDGRID(x1gv, x2gv) will output arrays of size M-by-N while 
  22 
%   MESHGRID(x1gv, x2gv) outputs arrays of size N-by-M. Similarly,
  23 
%   NDGRID(x1gv, x2gv, x3gv) will output arrays of size M-by-N-by-P while 
  24 
%   MESHGRID(x1gv, x2gv, x3gv) outputs arrays of size N-by-M-by-P.
  25 
%
  26 
%   Example: Evaluate the function  x2*exp(-x1^2-x2^2-x^3) over the
  27 
%            range  -2 < x1 < 2,  -2 < x2 < 2, -2 < x3 < 2,
  28 
%
  29 
%       [x1,x2,x3] = ndgrid(-2:.2:2, -2:.25:2, -2:.16:2);
  30 
%       z = x2 .* exp(-x1.^2 - x2.^2 - x3.^2);
  31 
%       slice(x2,x1,x3,z,[-1.2 .8 2],2,[-2 -.2])
  32 
%
  33 
%
  34 
%   Class support for inputs x1gv,x2gv,x3gv,...
  35 
%      float: double, single
  36 
%      integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64
  37 
%
  38 
%   See also MESHGRID, SLICE, INTERPN.
  39 

  40 
%   Copyright 1984-2013 The MathWorks, Inc. 
  41 

< 0.001 
     30 
  42
if nargin==0 || (nargin > 1 && nargout > nargin) 
  43 
   error(message('MATLAB:ndgrid:NotEnoughInputs'));    
  44 
end
< 0.001 
     30 
  45
nout = max(nargout,nargin); 
< 0.001 
     30 
  46
if nargin==1 
  47 
    if nargout < 2
  48 
        varargout{1} = varargin{1}(:);    
  49 
        return
  50 
    else
  51 
        j = ones(nout,1);
  52 
        siz(1:nout) = numel(varargin{1});
  53 
    end
< 0.001 
     30 
  54
else  
< 0.001 
     30 
  55
    j = 1:nout; 
  0.002 
     30 
  56
    siz = cellfun(@numel,varargin); 
< 0.001 
     30 
  57
end 
  58 

< 0.001 
     30 
  59
varargout = cell(1,max(nargout,1)); 
< 0.001 
     30 
  60
if nout == 2 % Optimized Case for 2 dimensions 
< 0.001 
     30 
  61
    x = full(varargin{j(1)}(:)); 
< 0.001 
     30 
  62
    y = full(varargin{j(2)}(:)).'; 
  0.083 
     30 
  63
    varargout{1} = repmat(x,size(y)); 
  0.083 
     30 
  64
    varargout{2} = repmat(y,size(x)); 
  65 
else
  66 
    for i=1:max(nargout,1)
  67 
        x = full(varargin{j(i)});
  68 
        s = ones(1,nout); 
  69 
        s(i) = numel(x);
  70 
        x = reshape(x,s);
  71 
        s = siz; 
  72 
        s(i) = 1;
  73 
        varargout{i} = repmat(x,s);
  74 
    end
< 0.001 
     30 
  75
end 

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