source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/ndgridmat.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 689 bytes
Line 
1function x = ndgridmat(varargin)
2%NDGRIDMAT  Matrix of grid points.
3% y = NDGRIDMAT(x1,x2,...) returns one matrix containing all grid points
4% as rows.  It is the same as concatenating the results of NDGRID.
5% First dimension varies fastest:
6% y(1,:) = [x1(1) x2(1) ...]
7% y(2,:) = [x1(2) x2(1) ...]
8
9% Written by Tom Minka
10% (c) Microsoft Corporation. All rights reserved.
11
12d = length(varargin);
13if d == 1
14  x = varargin{1}(:);
15  return;
16end
17
18len = zeros(1,d);
19for i = 1:d
20  len(i) = length(varargin{i});
21end
22n = prod(len);
23x = zeros(n,d);
24k = 1;
25for i = 1:d
26  xi = varargin{i}(:);
27  % might use reparray here
28  x(:,i) = repmat(kron(xi, ones(k,1)), n/k/len(i), 1);
29  k = k * len(i);
30end
Note: See TracBrowser for help on using the repository browser.