1 ## Copyright (C) 2010 Soren Hauberg <soren@hauberg.org>
3 ## This program is free software; you can redistribute it and/or modify it
4 ## under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 3 of the License, or (at
6 ## your option) any later version.
8 ## This program is distributed in the hope that it will be useful, but
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; see the file COPYING. If not, see
15 ## <http://www.gnu.org/licenses/>.
18 ## @deftypefn {Function File} {} gplot3 (@var{a}, @var{xyz})
19 ## @deftypefnx {Function File} {} gplot3 (@var{a}, @var{xyz}, @var{line_style})
20 ## @deftypefnx {Function File} {[@var{x}, @var{y}, @var{z}] =} gplot3 (@var{a}, @var{xyz})
21 ## Plot a 3-dimensional graph defined by @var{A} and @var{xyz} in the
22 ## graph theory sense. @var{A} is the adjacency matrix of the array to
23 ## be plotted and @var{xy} is an @var{n}-by-3 matrix containing the
24 ## coordinates of the nodes of the graph.
26 ## The optional parameter @var{line_style} defines the output style for
27 ## the plot. Called with no output arguments the graph is plotted
28 ## directly. Otherwise, return the coordinates of the plot in @var{x}
30 ## @seealso{gplot, treeplot, etreeplot, spy}
33 function [x, y, z] = gplot3 (A, xyz, varargin)
39 if (length (varargin) == 0)
44 xcoord = [xyz(i,1), xyz(j,1), NA(length(i),1)]'(:);
45 ycoord = [xyz(i,2), xyz(j,2), NA(length(i),1)]'(:);
46 zcoord = [xyz(i,3), xyz(j,3), NA(length(i),1)]'(:);
49 plot3 (xcoord, ycoord, zcoord, varargin {:});
59 %! ## Define adjacency matrix of a graph with 5 nodes
60 %! A = [0, 1, 0, 0, 1;
66 %! ## Define 3D points of the nodes
73 %! ## Plot the 3D graph