Mercurial > hg > octave-lyh
annotate scripts/plot/surfc.m @ 12812:4c93cc41da15 stable
codesprint: add demo for surf.m and surfc.m
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Sat, 16 Jul 2011 20:56:20 +0200 |
parents | b0084095098e |
children | b00181c65533 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1996-2011 John W. Eaton |
7118 | 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 | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License 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, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} surfc (@var{x}, @var{y}, @var{z}) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
21 ## Plot a surface and contour given matrices @var{x}, and @var{y} from |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
22 ## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
23 ## @var{y} coordinates of the mesh. If @var{x} and @var{y} are vectors, |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
24 ## then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus, |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
25 ## columns of @var{z} correspond to different @var{x} values and rows of |
7118 | 26 ## @var{z} correspond to different @var{y} values. |
27 ## @seealso{meshgrid, surf, contour} | |
28 ## @end deftypefn | |
29 | |
30 function h = surfc (varargin) | |
31 | |
32 newplot (); | |
33 | |
34 tmp = surface (varargin{:}); | |
35 | |
36 ax = get (tmp, "parent"); | |
37 | |
38 set (tmp, "facecolor", "flat"); | |
39 | |
7146 | 40 if (! ishold ()) |
11427
dc983f92e774
contour3.m: Grid on be default for 3D plots.
Ben Abbott <bpabbott@mac.com>
parents:
11426
diff
changeset
|
41 set (ax, "view", [-37.5, 30], |
dc983f92e774
contour3.m: Grid on be default for 3D plots.
Ben Abbott <bpabbott@mac.com>
parents:
11426
diff
changeset
|
42 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
7146 | 43 endif |
7118 | 44 |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
45 drawnow (); |
11426
c503ccbe5033
Place contour for meshc/surfc at zlim(1)
Ben Abbott <bpabbott@mac.com>
parents:
7208
diff
changeset
|
46 zmin = get (ax, "zlim")(1); |
7118 | 47 |
7170 | 48 [c, tmp2] = __contour__ (ax, zmin, varargin{:}); |
7118 | 49 |
7170 | 50 tmp = [tmp; tmp2]; |
7118 | 51 |
52 if (nargout > 0) | |
53 h = tmp; | |
54 endif | |
7146 | 55 |
7118 | 56 endfunction |
12812
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
57 |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
58 %!demo |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
59 %! clf |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
60 %! [~,~,Z]=peaks; |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
61 %! surfc(Z); |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
62 |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
63 %!demo |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
64 %! [~,~,Z]=sombrero; |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
65 %! [Fx,Fy] = gradient(Z); |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
66 %! surfc(Z,Fx+Fy); |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
67 %! shading interp; |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
68 |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
69 %!demo |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
70 %! [X,Y,Z]=sombrero; |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
71 %! [~,Fy] = gradient(Z); |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
72 %! surfc(X,Y,Z,Fy); |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11589
diff
changeset
|
73 %! shading interp; |