2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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 2, or (at your option) |
|
8 ## 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, write to the Free |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, USA. |
245
|
19 |
3449
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} __plt2mv__ (@var{x}, @var{y}, @var{fmt}) |
|
22 ## @end deftypefn |
3402
|
23 |
2314
|
24 ## Author: jwe |
|
25 |
2315
|
26 function __plt2mv__ (x, y, fmt) |
4
|
27 |
934
|
28 if (nargin < 2 || nargin > 3) |
2315
|
29 msg = sprintf ("__plt2mv__ (x, y)\n"); |
|
30 msg = sprintf ("%s __plt2mv__ (x, y, fmt)", msg); |
934
|
31 usage (msg); |
3162
|
32 elseif (nargin == 2 || fmt == "") |
|
33 fmt = " "; ## Yes, this is intentionally not an empty string! |
4
|
34 endif |
|
35 |
|
36 [x_nr, x_nc] = size (x); |
|
37 [y_nr, y_nc] = size (y); |
|
38 |
|
39 if (y_nr == 1) |
|
40 y = y'; |
|
41 tmp = y_nr; |
|
42 y_nr = y_nc; |
|
43 y_nc = tmp; |
|
44 endif |
|
45 |
|
46 if (x_nr == y_nr) |
|
47 1; |
|
48 elseif (x_nc == y_nr) |
|
49 x = x'; |
|
50 tmp = x_nr; |
|
51 x_nr = x_nc; |
|
52 x_nc = tmp; |
|
53 else |
2315
|
54 error ("__plt2mv__: matrix dimensions must match"); |
4
|
55 endif |
|
56 |
3162
|
57 k = 1; |
|
58 fmt_nr = rows (fmt); |
4
|
59 if (x_nc > 0) |
|
60 tmp = [x, y]; |
3162
|
61 cmd = sprintf ("gplot tmp(:,%d:%d:%d) %s", 1, x_nc, x_nc+1, |
4260
|
62 deblank (fmt (k, :))); |
3162
|
63 if (k < fmt_nr) |
|
64 k++; |
|
65 endif |
4
|
66 for i = 2:x_nc |
3162
|
67 cmd = sprintf ("%s, tmp(:,%d:%d:%d) %s", cmd, i, x_nc-i+1, x_nc+1, |
4260
|
68 deblank (fmt (k, :))); |
3162
|
69 if (k < fmt_nr) |
3426
|
70 k++; |
3162
|
71 endif |
4
|
72 endfor |
934
|
73 eval (cmd); |
4
|
74 else |
2315
|
75 error ("__plt2mv__: arguments must be a matrices"); |
4
|
76 endif |
|
77 |
|
78 endfunction |