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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
245
|
19 |
3449
|
20 ## -*- texinfo -*- |
5115
|
21 ## @deftypefn {Function File} {[data, fmtstr] =} __plt2vm__ (@var{x}, @var{y}, @var{fmt}) |
3449
|
22 ## @end deftypefn |
3402
|
23 |
2314
|
24 ## Author: jwe |
|
25 |
6146
|
26 function [data, fmtstr, key] = __plt2vm__ (x, y, fmt, keystr) |
|
27 |
|
28 if (nargin < 2 || nargin > 4 || nargout < 2 || nargout > 3) |
|
29 print_usage (); |
|
30 endif |
4
|
31 |
6146
|
32 if (nargin < 3 || isempty (fmt)) |
|
33 fmt = {""}; |
|
34 endif |
|
35 |
|
36 if (nargin < 4 || isempty (keystr)) |
|
37 keystr = {""}; |
4
|
38 endif |
|
39 |
|
40 [x_nr, x_nc] = size (x); |
|
41 [y_nr, y_nc] = size (y); |
|
42 |
|
43 if (x_nr == 1) |
|
44 x = x'; |
|
45 tmp = x_nr; |
|
46 x_nr = x_nc; |
|
47 x_nc = tmp; |
|
48 endif |
|
49 |
|
50 if (x_nr == y_nr) |
|
51 1; |
|
52 elseif (x_nr == y_nc) |
|
53 y = y'; |
|
54 tmp = y_nr; |
|
55 y_nr = y_nc; |
|
56 y_nc = tmp; |
|
57 else |
2315
|
58 error ("__plt2vm__: matrix dimensions must match"); |
4
|
59 endif |
|
60 |
|
61 if (y_nc > 0) |
5115
|
62 if (rows (fmt) == 1) |
|
63 fmt = repmat (fmt, y_nc, 1); |
3162
|
64 endif |
6146
|
65 if (rows (keystr) == 1) |
|
66 keystr = repmat (keystr, y_nc, 1); |
|
67 endif |
5115
|
68 tmp = [x, y]; |
|
69 dtmp = cell (y_nc, 1); |
|
70 ftmp = cell (y_nc, 1); |
6146
|
71 ktmp = cell (y_nc, 1); |
5115
|
72 for i = 1:y_nc |
|
73 dtmp{i} = tmp(:,[1,i+1]); |
6146
|
74 ftmp{i} = deblank (fmt{i}); |
|
75 ktmp{i} = deblank (keystr{i}); |
4
|
76 endfor |
5115
|
77 data = dtmp; |
|
78 fmtstr = ftmp; |
6146
|
79 key = ktmp; |
4
|
80 else |
2315
|
81 error ("__plt2vm__: arguments must be a matrices"); |
4
|
82 endif |
|
83 |
|
84 endfunction |