Mercurial > hg > octave-lyh
comparison scripts/plot/contour.m @ 4:b4df021f796c
[project @ 1993-08-08 01:26:08 by jwe]
Initial revision
author | jwe |
---|---|
date | Sun, 08 Aug 1993 01:26:08 +0000 |
parents | |
children | 16a24e76d6e0 |
comparison
equal
deleted
inserted
replaced
3:9a4c07481e61 | 4:b4df021f796c |
---|---|
1 function contour (z, n, x, y) | |
2 | |
3 # usage: contour (z, n, x, y) | |
4 # | |
5 # See also: plot, semilogx, semilogy, loglog, polar, mesh, contour, | |
6 # bar, stairs, gplot, gsplot, replot, xlabel, ylabel, title | |
7 | |
8 | |
9 if (nargin == 1) | |
10 n = 10; | |
11 endif | |
12 | |
13 if (nargin == 1 || nargin == 2) | |
14 if (is_matrix (z)) | |
15 set nosurface; | |
16 set contour; | |
17 set cntrparam bspline | |
18 command = sprintf ("set cntrparam levels %d", n); | |
19 eval (command); | |
20 set noparametric; | |
21 set view 0, 0, 1.9, 1 | |
22 gsplot z w l 1; | |
23 else | |
24 error ("mesh: argument must be a matrix"); | |
25 endif | |
26 elseif (nargin == 4) | |
27 if (is_vector (x) && is_vector (y) && is_matrix (z)) | |
28 xlen = length (x); | |
29 ylen = length (y); | |
30 if (xlen == rows (z) && ylen == columns (z)) | |
31 if (rows (x) == 1) | |
32 x = x'; | |
33 endif | |
34 len = 3 * ylen; | |
35 zz = zeros (xlen, ylen); | |
36 k = 1; | |
37 for i = 1:3:len | |
38 zz(:,i) = x; | |
39 zz(:,i+1) = y(k) * ones (xlen, 1); | |
40 zz(:,i+2) = z(:,k); | |
41 k++; | |
42 endfor | |
43 set nosurface | |
44 set contour | |
45 set cntrparam bspline | |
46 command = sprintf ("set cntrparam levels %d", n); | |
47 eval (command); | |
48 set parametric; | |
49 set view 0, 0, 1.9, 1 | |
50 gsplot zz w l 1; | |
51 else | |
52 disp ("mesh: rows (z) must be the same as length (x)"); | |
53 error (" and columns (z) must be the same as length (y)"); | |
54 endif | |
55 else | |
56 error ("mesh: x and y must be vectors and z must be a matrix"); | |
57 endif | |
58 else | |
59 error ("usage: mesh (z, levels, x, y)"); | |
60 endif | |
61 | |
62 endfunction |