```Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: 3D points representing cubes to 3D surface?
Date: Sat, 24 Nov 2012 09:12:08 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 24
Message-ID: <k8q318\$lgh\$1@newscl01ah.mathworks.com>
References: <k8ntuj\$aii\$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1353748328 22033 172.30.248.46 (24 Nov 2012 09:12:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 24 Nov 2012 09:12:08 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:783378

Here is a function that build edge topology for any dimension. Using this code we can see the number of edge hypercube in a 13th dimensional space is 53248.

n=3

c = repmat({[0 1]},[1 n]);
[c{:}] = ndgrid(c{:});
c = cat(n+1,c{:});
c = reshape(c,[],n);
[i, d] = ndgrid((1:2^n)',2.^(0:n-1));
j = (1-c) .* (i+d);
b = j>0;
e = [i(b) j(b)];

xyz = c(e',:);
xyz = reshape(xyz, 2, [], n);
xyz = num2cell(xyz,[1 2]);

if n==2
plot(xyz{:});
elseif n==3
plot3(xyz{:});
end

% Bruno
```