Mercurial > octave
annotate scripts/plot/draw/streamline.m @ 28135:695bb31e565b stable
Rename "streamtube" to "ostreamtube" (bug #57471).
* ostreamtube.m: Rename from "streamtube.m" ahead of adding a Matlab compatible
"streamtube" function.
* stream3.m, streamline.m, module.mk, plot.txi, NEWS: Change all references.
author | Markus Meisinger <chloros2@gmx.de> |
---|---|
date | Wed, 19 Feb 2020 07:53:10 +0100 |
parents | bd51beb6205e |
children | 23f667483fab |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 ## Copyright (C) 2019-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27810
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
7 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
9 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
13 ## (at your option) any later version. |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
14 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
18 ## GNU General Public License for more details. |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
19 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
25 |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
27 ## @deftypefn {} {} streamline (@var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w}, @var{sx}, @var{sy}, @var{sz}) |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
28 ## @deftypefnx {} {} streamline (@var{u}, @var{v}, @var{w}, @var{sx}, @var{sy}, @var{sz}) |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
29 ## @deftypefnx {} {} streamline (@dots{}, @var{options}) |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
30 ## @deftypefnx {} {} streamline (@var{hax}, @dots{}) |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
31 ## @deftypefnx {} {@var{h} =} streamline (@dots{}) |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
32 ## Plot streamlines of 2-D or 3-D vector fields. |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
33 ## |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
34 ## Plot streamlines of a 2-D or 3-D vector field given by |
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
35 ## @code{[@var{u}, @var{v}]} or @code{[@var{u}, @var{v}, @var{w}]}. The vector |
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
36 ## field is defined over a rectangular grid given by @code{[@var{x}, @var{y}]} |
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
37 ## or @code{[@var{x}, @var{y}, @var{z}]}. The streamlines start at the seed |
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
38 ## points @code{[@var{sx}, @var{sy}]} or @code{[@var{sx}, @var{sy}, @var{sz}]}. |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
39 ## |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
40 ## The input parameter @var{options} is a 2-D vector of the form |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
41 ## @code{[@var{stepsize}, @var{max_vertices}]}. The first parameter |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
42 ## specifies the step size used for trajectory integration (default 0.1). A |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
43 ## negative value is allowed which will reverse the direction of integration. |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
44 ## The second parameter specifies the maximum number of segments used to |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27759
diff
changeset
|
45 ## create a streamline (default 10,000). |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
46 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
47 ## If the first argument @var{hax} is an axes handle, then plot into this axes, |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
48 ## rather than the current axes returned by @code{gca}. |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
49 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
50 ## The optional return value @var{h} is a graphics handle to the hggroup |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
51 ## comprising the field lines. |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
52 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
53 ## Example: |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
54 ## |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
55 ## @example |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
56 ## @group |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
57 ## [x, y] = meshgrid (-1.5:0.2:2, -1:0.2:2); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
58 ## u = - x / 4 - y; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
59 ## v = x - y / 4; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
60 ## streamline (x, y, u, v, 1.7, 1.5); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
61 ## @end group |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
62 ## @end example |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
63 ## |
28135
695bb31e565b
Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents:
27923
diff
changeset
|
64 ## @seealso{stream2, stream3, ostreamtube} |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
65 ## @end deftypefn |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
66 |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
67 function h = streamline (varargin) |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
68 |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
69 [hax, varargin, nargin] = __plt_get_axis_arg__ ("streamline", varargin{:}); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
70 |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
71 if (nargin == 0) |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
72 print_usage (); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
73 endif |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
74 |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
75 nd = ndims (varargin{1}); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
76 if (nd > 3) |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
77 error ("streamline: input data must be 2-D or 3-D"); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
78 endif |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
79 |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
80 if (isempty (hax)) |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
81 hax = gca (); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
82 else |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
83 hax = hax(1); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
84 endif |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
85 |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
86 h = []; |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
87 if (nd == 2) |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
88 xy = stream2 (varargin{:}); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
89 for i = 1 : length (xy) |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
90 sl = xy{i}; |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
91 if (! isempty (sl)) |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
92 htmp = line (hax, "xdata", sl(:, 1), "ydata", sl(:, 2), "color", "b"); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
93 h = [h; htmp]; |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
94 endif |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
95 endfor |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
96 else |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
97 xyz = stream3 (varargin{:}); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
98 for i = 1 : length (xyz) |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
99 sl = xyz{i}; |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
100 if (! isempty (sl)) |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
101 htmp = line (hax, |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
102 "xdata", sl(:, 1), "ydata", sl(:, 2), "zdata", sl(:, 3), |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
103 "color", "b"); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
104 h = [h; htmp]; |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
105 endif |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
106 endfor |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
107 endif |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
108 |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
109 endfunction |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
110 |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
111 |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
112 %!demo |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
113 %! clf; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
114 %! [x, y] = meshgrid (-2:0.5:2); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
115 %! u = - y - x / 2; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
116 %! v = x - y / 2; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
117 %! [sx, sy] = meshgrid (-2:2:2); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
118 %! h = streamline (x, y, u, v, sx, sy); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
119 %! set (h, "color", "r"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
120 %! hold on; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
121 %! quiver (x, y, u, v); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
122 %! scatter (sx(:), sy(:), 20, "filled", "o", "markerfacecolor", "r"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
123 %! title ("Spiral Sink"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
124 %! grid on; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
125 %! axis equal; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
126 |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
127 %!demo |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
128 %! clf; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
129 %! [x, y, z] = meshgrid (-3:3); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
130 %! u = - x / 2 - y; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
131 %! v = x - y / 2; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
132 %! w = - z; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
133 %! [sx, sy, sz] = meshgrid (3, 0:1.5:1.5, 0:1.5:3); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
134 %! h = streamline (x, y, z, u, v, w, sx, sy, sz); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
135 %! set (h, "color", "r"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
136 %! hold on; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
137 %! quiver3 (x, y, z, u, v, w); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
138 %! scatter3 (sx(:), sy(:), sz(:), 20, "filled", "o", "markerfacecolor", "r"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
139 %! view (3); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
140 %! title ("Spiral Sink"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
141 %! grid on; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
142 %! axis equal; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
143 |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
144 %!demo |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
145 %! clf; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
146 %! [x, y, z] = meshgrid (-1:0.4:1, -1:0.4:1, -3:0.3:0); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
147 %! a = 0.08; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
148 %! b = 0.04; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
149 %! u = - a * x - y; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
150 %! v = x - a * y; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
151 %! w = - b * ones (size (x)); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
152 %! hold on; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
153 %! sx = 1.0; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
154 %! sy = 0.0; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
155 %! sz = 0.0; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
156 %! plot3 (sx, sy, sz, ".r", "markersize", 15); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
157 %! t = linspace (0, 12 * 2 * pi(), 500); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
158 %! tx = exp (-a * t).*cos (t); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
159 %! ty = exp (-a * t).*sin (t); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
160 %! tz = - b * t; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
161 %! plot3 (tx, ty, tz, "-b"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
162 %! h = streamline (x, y, z, u, v, w, sx, sy, sz); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
163 %! set (h, "color", "r"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
164 %! view (3); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
165 %! title ("Heuns Scheme (red) vs. Analytical Solution (blue)"); |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
166 %! grid on; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
167 %! axis equal tight; |
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
168 |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
169 ## Test input validation |
27759
992e702ef0d7
Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
170 %!error streamline () |
27810
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
171 %!error <Invalid call to streamline> |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
172 %! hf = figure ("visible", "off"); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
173 %! unwind_protect |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
174 %! hax = axes (); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
175 %! streamline (hax); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
176 %! unwind_protect_cleanup |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
177 %! close (hf); |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
178 %! end_unwind_protect |
f2b89a2e20b6
overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents:
27794
diff
changeset
|
179 %!error <input data must be 2-D or 3-D> streamline (ones (2,2,2,2)) |