Mercurial > hg > octave-nkf
annotate scripts/plot/meshz.m @ 15137:16a6b0a6855d gui
GUI: support for octave arguments and integrate with run-octave.
* src/octave.h (octave_initialize_interpreter, octave_execute_interpreter):
New functions.
(octave_cmdline_argc, octave_cmdline_argv, octave_embedded): New variables.
* src/octave.cc (octave_cmdline_argc, octave_cmdline_argv, octave_embedded):
New variables.
(octave_initialize_interpreter, octave_execute_interpreter): New functions.
(octave_main): Rewrite using them.
* run-octave.in (octave_executable): New variable.
(-gui): New option flag.
* gui/src/octave-adapter/octave-main-thread.cc (octave_main_thread::run):
Use octave_execute_interpreter.
* gui/src/octave-gui.cc (dissociate_terminal): New function.
(main): Use it. Also use octave_initialize_interpreter.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 Aug 2012 16:15:58 -0400 |
parents | c2dbdeaa25df |
children | c9346014fed2 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
1 ## Copyright (C) 2007-2012 David Bateman |
7207 | 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} {} meshz (@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 curtain mesh 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 |
7207 | 26 ## @var{z} correspond to different @var{y} values. |
27 ## @seealso{meshgrid, mesh, contour} | |
28 ## @end deftypefn | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
29 |
7207 | 30 function retval = meshz (varargin) |
31 | |
7215 | 32 [h, varargin, nargin] = __plt_get_axis_arg__ ("meshz", varargin{:}); |
7207 | 33 |
34 ioff = nargin + 1; | |
7216 | 35 for i = 1:nargin |
7208 | 36 if (ischar (varargin{i})) |
7207 | 37 ioff = i; |
38 break; | |
39 endif | |
40 endfor | |
41 | |
42 ## Bundle C matrix back into varargin | |
43 if (ioff == 3 || ioff == 5) | |
44 ioff --; | |
45 endif | |
46 | |
47 if (ioff == 2) | |
7208 | 48 z = varargin{1}; |
7207 | 49 [m, n] = size (z); |
7216 | 50 x = 1:n; |
51 y = (1:m).'; | |
7207 | 52 else |
7208 | 53 x = varargin{1}; |
54 y = varargin{2}; | |
55 z = varargin{3}; | |
7207 | 56 endif |
57 | |
58 | |
59 if (isvector (x) && isvector (y)) | |
60 x = [x(1), x(:).', x(end)]; | |
61 y = [y(1); y(:); y(end)]; | |
62 else | |
63 x = [x(1, 1), x(1, :), x(1, end); | |
10549 | 64 x(:, 1), x, x(:, end); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
65 x(end, 1), x(end, :), x(end, end)]; |
7207 | 66 y = [y(1, 1), y(1, :), y(1, end); |
10549 | 67 y(:, 1), y, y(:, end); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
68 y(end, 1), y(end, :), y(end, end)]; |
7207 | 69 endif |
70 | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
71 zref = min (z(isfinite (z))); |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
72 z = [zref .* ones(1, columns(z) + 2); |
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
73 zref .* ones(rows(z), 1), z, zref .* ones(rows(z), 1); |
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
74 zref.* ones(1, columns(z) + 2)]; |
7207 | 75 |
7215 | 76 oldh = gca (); |
77 unwind_protect | |
78 axes (h); | |
79 tmp = mesh (x, y, z, varargin{ioff:end}); | |
80 unwind_protect_cleanup | |
81 axes (oldh); | |
82 end_unwind_protect | |
83 | |
84 if (nargout > 0) | |
85 retval = tmp; | |
86 endif | |
7207 | 87 |
88 endfunction |