1014
|
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton |
245
|
2 # |
|
3 # This file is part of Octave. |
|
4 # |
|
5 # Octave is free software; you can redistribute it and/or modify it |
|
6 # under the terms of the GNU General Public License as published by the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # for more details. |
|
14 # |
|
15 # You should have received a copy of the GNU General Public License |
|
16 # along with Octave; see the file COPYING. If not, write to the Free |
1315
|
17 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
245
|
18 |
4
|
19 function contour (z, n, x, y) |
|
20 |
|
21 # usage: contour (z, n, x, y) |
|
22 # |
|
23 # See also: plot, semilogx, semilogy, loglog, polar, mesh, contour, |
|
24 # bar, stairs, gplot, gsplot, replot, xlabel, ylabel, title |
|
25 |
|
26 |
|
27 if (nargin == 1) |
|
28 n = 10; |
|
29 endif |
|
30 |
|
31 if (nargin == 1 || nargin == 2) |
|
32 if (is_matrix (z)) |
|
33 set nosurface; |
|
34 set contour; |
|
35 set cntrparam bspline |
|
36 command = sprintf ("set cntrparam levels %d", n); |
|
37 eval (command); |
|
38 set noparametric; |
|
39 set view 0, 0, 1.9, 1 |
|
40 gsplot z w l 1; |
|
41 else |
|
42 error ("mesh: argument must be a matrix"); |
|
43 endif |
|
44 elseif (nargin == 4) |
|
45 if (is_vector (x) && is_vector (y) && is_matrix (z)) |
|
46 xlen = length (x); |
|
47 ylen = length (y); |
|
48 if (xlen == rows (z) && ylen == columns (z)) |
|
49 if (rows (x) == 1) |
|
50 x = x'; |
|
51 endif |
|
52 len = 3 * ylen; |
|
53 zz = zeros (xlen, ylen); |
|
54 k = 1; |
|
55 for i = 1:3:len |
|
56 zz(:,i) = x; |
|
57 zz(:,i+1) = y(k) * ones (xlen, 1); |
|
58 zz(:,i+2) = z(:,k); |
|
59 k++; |
|
60 endfor |
|
61 set nosurface |
|
62 set contour |
|
63 set cntrparam bspline |
|
64 command = sprintf ("set cntrparam levels %d", n); |
|
65 eval (command); |
|
66 set parametric; |
|
67 set view 0, 0, 1.9, 1 |
|
68 gsplot zz w l 1; |
|
69 else |
904
|
70 msg = "mesh: rows (z) must be the same as length (x) and"; |
|
71 msg = sprintf ("%s\ncolumns (z) must be the same as length (y)", msg); |
|
72 error (msg); |
4
|
73 endif |
|
74 else |
|
75 error ("mesh: x and y must be vectors and z must be a matrix"); |
|
76 endif |
|
77 else |
904
|
78 usage ("mesh (z, levels, x, y)"); |
4
|
79 endif |
|
80 |
|
81 endfunction |