4
|
1 function mesh (x, y, z) |
|
2 |
|
3 # usage: mesh (x, y, z) |
|
4 # |
|
5 # See also: plot, semilogx, semilogy, loglog, polar, meshdom, contour, |
|
6 # bar, stairs, gplot, gsplot, replot, xlabel, ylabel, title |
|
7 |
|
8 if (nargin == 1) |
|
9 z = x; |
|
10 if (is_matrix (z)) |
|
11 set hidden3d; |
|
12 set data style lines; |
|
13 set surface; |
|
14 set nocontour; |
|
15 set noparametric; |
|
16 set view 60, 30, 1, 1 |
|
17 gsplot (z); |
|
18 else |
|
19 error ("mesh: argument must be a matrix"); |
|
20 endif |
|
21 elseif (nargin == 3) |
|
22 if (is_vector (x) && is_vector (y) && is_matrix (z)) |
|
23 xlen = length (x); |
|
24 ylen = length (y); |
|
25 if (xlen == rows (z) && ylen == columns (z)) |
|
26 if (rows (x) == 1) |
|
27 x = x'; |
|
28 endif |
|
29 len = 3 * ylen; |
|
30 zz = zeros (xlen, ylen); |
|
31 k = 1; |
|
32 for i = 1:3:len |
|
33 zz(:,i) = x; |
|
34 zz(:,i+1) = y(k) * ones (xlen, 1); |
|
35 zz(:,i+2) = z(:,k); |
|
36 k++; |
|
37 endfor |
|
38 set hidden3d; |
|
39 set data style lines; |
|
40 set surface; |
|
41 set nocontour; |
|
42 set parametric; |
|
43 set view 60, 30, 1, 1 |
|
44 gsplot (zz); |
|
45 else |
|
46 disp ("mesh: rows (z) must be the same as length (x)"); |
|
47 error (" and columns (z) must be the same as length (y)"); |
|
48 endif |
|
49 else |
|
50 error ("mesh: x and y must be vectors and z must be a matrix"); |
|
51 endif |
|
52 else |
|
53 error ("usage: mesh (z)"); |
|
54 endif |
|
55 |
|
56 endfunction |