This is a static copy of a profile report

Home

meshgrid (3 calls, 0.013 sec)
Generated 04-Aug-2014 13:05:14 using cpu time.
function in file /share/apps/matlabr2014a/toolbox/matlab/elmat/meshgrid.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
meshdomainfunction3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
59
yy = repmat(ycol,size(xrow));
30.013 s100.0%
60
end
30 s0%
58
xx = repmat(xrow,size(ycol));
30 s0%
57
ycol = full(y(:));   % Make su...
30 s0%
56
xrow = full(x(:)).'; % Make su...
30 s0%
All other lines  0 s0%
Totals  0.013 s100% 
Children (called functions)
No children
Code Analyzer results
Line numberMessage
53Consider using ZEROS(..., 'like', X ) instead of ZEROS(..., class(X) ).
54Consider using ZEROS(..., 'like', X ) instead of ZEROS(..., class(X) ).
67Consider using ZEROS(..., 'like', X ) instead of ZEROS(..., class(X) ).
68Consider using ZEROS(..., 'like', X ) instead of ZEROS(..., class(X) ).
69Consider using ZEROS(..., 'like', X ) instead of ZEROS(..., class(X) ).
Coverage results
Show coverage for parent directory
Total lines in function81
Non-code lines (comments, blank lines)44
Code lines (lines that can run)37
Code lines that did run10
Code lines that did not run27
Coverage (did run/can run)27.03 %
Function listing
time 
calls 
 line
   1 
function [xx,yy,zz] = meshgrid(x,y,z)
   2 
%MESHGRID   Cartesian grid in 2-D/3-D space
   3 
%   [X,Y] = MESHGRID(xgv,ygv) replicates the grid vectors xgv and ygv to 
   4 
%   produce the coordinates of a rectangular grid (X, Y). The grid vector
   5 
%   xgv is replicated numel(ygv) times to form the columns of X. The grid 
   6 
%   vector ygv is replicated numel(xgv) times to form the rows of Y.
   7 
%
   8 
%   [X,Y,Z] = MESHGRID(xgv,ygv,zgv) replicates the grid vectors xgv, ygv, zgv 
   9 
%   to produce the coordinates of a 3D rectangular grid (X, Y, Z). The grid 
  10 
%   vectors xgv,ygv,zgv form the columns of X, rows of Y, and pages of Z 
  11 
%   respectively. (X,Y,Z) are of size numel(ygv)-by-numel(xgv)-by(numel(zgv).
  12 
%
  13 
%   [X,Y] = MESHGRID(gv) is equivalent to [X,Y] = MESHGRID(gv,gv).
  14 
%   [X,Y,Z] = MESHGRID(gv) is equivalent to [X,Y,Z] = MESHGRID(gv,gv,gv).
  15 
%
  16 
%   The coordinate arrays are typically used for the evaluation of functions 
  17 
%   of two or three variables and for surface and volumetric plots.
  18 
%
  19 
%   MESHGRID and NDGRID are similar, though MESHGRID is restricted to 2-D 
  20 
%   and 3-D while NDGRID supports 1-D to N-D. In 2-D and 3-D the coordinates 
  21 
%   output by each function are the same, the difference is the shape of the 
  22 
%   output arrays. For grid vectors xgv, ygv and zgv of length M, N and P 
  23 
%   respectively, NDGRID(xgv, ygv) will output arrays of size M-by-N while 
  24 
%   MESHGRID(xgv, ygv) outputs arrays of size N-by-M. Similarly, 
  25 
%   NDGRID(xgv, ygv, zgv) will output arrays of size M-by-N-by-P while 
  26 
%   MESHGRID(xgv, ygv, zgv) outputs arrays of size N-by-M-by-P. 
  27 
%
  28 
%   Example: Evaluate the function  x*exp(-x^2-y^2) 
  29 
%            over the range  -2 < x < 2,  -4 < y < 4,
  30 
%
  31 
%       [X,Y] = meshgrid(-2:.2:2, -4:.4:4);
  32 
%       Z = X .* exp(-X.^2 - Y.^2);
  33 
%       surf(X,Y,Z)
  34 
%
  35 
%
  36 
%   Class support for inputs xgv,ygv,zgv:
  37 
%      float: double, single
  38 
%      integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64
  39 
%
  40 
%   See also SURF, SLICE, NDGRID.
  41 

  42 
%   Copyright 1984-2013 The MathWorks, Inc. 
  43 

      3 
  44 
if nargin==0 || (nargin > 1 && nargout > nargin) 
  45 
    error(message('MATLAB:meshgrid:NotEnoughInputs'));
  46 
end
  47 

      3 
  48 
if nargin == 2 || (nargin == 1 && nargout < 3) % 2-D array case 
      3 
  49 
    if nargin == 1 
  50 
        y = x;
  51 
    end
      3 
  52 
    if isempty(x) || isempty(y) 
  53 
        xx = zeros(0,class(x));
  54 
        yy = zeros(0,class(y));
      3 
  55 
    else 
      3 
  56 
        xrow = full(x(:)).'; % Make sure x is a full row vector. 
      3 
  57 
        ycol = full(y(:));   % Make sure y is a full column vector. 
      3 
  58 
        xx = repmat(xrow,size(ycol)); 
  0.01 
      3 
  59 
        yy = repmat(ycol,size(xrow)); 
      3 
  60 
    end 
  61 
else  % 3-D array case
  62 
    if nargin == 1
  63 
        y = x;
  64 
        z = x;
  65 
    end
  66 
    if isempty(x) || isempty(y) || isempty(z)
  67 
        xx = zeros(0,class(x));
  68 
        yy = zeros(0,class(y));
  69 
        zz = zeros(0,class(z));
  70 
    else
  71 
        nx = numel(x);
  72 
        ny = numel(y);
  73 
        nz = numel(z);
  74 
        xx = reshape(full(x),[1 nx 1]); % Make sure x is a full row vector.
  75 
        yy = reshape(full(y),[ny 1 1]); % Make sure y is a full column vector.
  76 
        zz = reshape(full(z),[1 1 nz]); % Make sure z is a full page vector.
  77 
        xx = repmat(xx, ny, 1, nz);
  78 
        yy = repmat(yy, 1, nx, nz);
  79 
        zz = repmat(zz, ny, nx, 1);
  80 
    end
  81 
end