4019
|
1 ## Copyright (C) 2001, 2002 Teemu Ikonen |
|
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. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} __errcomm__ (@var{args}) |
|
22 ## Common argument handling code for all error plots (errorbar, loglogerr, |
|
23 ## semilogyerr, semilogxerr). |
|
24 ## |
|
25 ## @end deftypefn |
|
26 ## @seealso{errorbar, semilogxerr, semilogyerr, loglogerr, __pltopt__} |
|
27 |
|
28 ## Created: 20.02.2001 |
|
29 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> |
|
30 ## Keywords: errorbar, plotting |
|
31 |
|
32 function __errcomm__ (caller, varargin) |
|
33 |
|
34 if (nargin < 3) |
|
35 usage ("%s (...)", caller); |
|
36 endif |
|
37 |
|
38 nargin--; |
|
39 save_hold = ishold; |
|
40 unwind_protect |
|
41 if (! ishold) |
|
42 clg |
|
43 endif |
|
44 hold on; |
|
45 k = 1; |
|
46 while (nargin) |
|
47 a = varargin{k++}; |
|
48 nargin--; |
|
49 if (is_vector (a)) |
|
50 a = a(:); |
|
51 elseif (is_matrix (a)) |
|
52 ; |
|
53 else |
|
54 usage ("%s (...)", caller); |
|
55 endif |
|
56 sz = size (a); |
|
57 ndata = 1; |
|
58 arg1 = a; |
|
59 while (nargin) |
|
60 nargin--; |
|
61 a = varargin{k++}; |
|
62 if (isstr (a)) |
|
63 fmt = a; |
|
64 cmd = "__errplot__ (arg1"; |
|
65 for i = 2:ndata, |
|
66 cmd = sprintf ("%s, arg%d", cmd, i); |
|
67 endfor |
|
68 eval (sprintf ("%s, fmt);", cmd)); |
|
69 break; |
|
70 elseif (is_vector (a)) |
|
71 a = a(:); |
|
72 elseif (is_matrix (a)) |
|
73 ; |
|
74 else |
|
75 error ("wrong argument types"); |
|
76 endif |
|
77 if (size (a) != sz) |
|
78 error ("argument sizes do not match"); |
|
79 endif |
|
80 ndata++; |
|
81 eval (sprintf ("arg%d = a;", ndata)); |
|
82 if (ndata > 6) |
|
83 error ("too many arguments to a plot"); |
|
84 endif |
|
85 endwhile |
|
86 endwhile |
|
87 |
|
88 if (! isstr (a)) |
4020
|
89 fmt = "~"; |
4019
|
90 cmd = "__errplot__ (arg1"; |
|
91 for i = 2:ndata, |
|
92 cmd = sprintf ("%s, arg%d", cmd, i); |
|
93 endfor |
|
94 eval (sprintf ("%s, fmt);", cmd)); |
|
95 endif |
|
96 unwind_protect_cleanup |
|
97 if (! save_hold) |
|
98 hold off; |
|
99 endif |
|
100 end_unwind_protect |
|
101 |
|
102 endfunction |