Mercurial > hg > octave-nkf
annotate scripts/deprecated/com2str.m @ 7696:0a362fa8f3c8
Add warning to rest of deprecated functions
author | David Bateman <dbateman@free.fr> |
---|---|
date | Fri, 04 Apr 2008 10:18:35 -0400 |
parents | 8e5371d47da6 |
children | 1cdb42b372e8 72830070a17b |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1998, 2004, 2005, 2006, 2007 |
2 ## Auburn University. All rights reserved. | |
4878 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7016 | 7 ## under the terms of the GNU General Public License as published by |
8 ## the Free Software Foundation; either version 3 of the License, or (at | |
9 ## your option) any later version. | |
4878 | 10 ## |
7016 | 11 ## Octave is distributed in the hope that it will be useful, but |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
4878 | 15 ## |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
4878 | 19 |
20 ## -*- texinfo -*- | |
21 ## @deftypefn {Function File} {} com2str (@var{zz}, @var{flg}) | |
22 ## This function has been deprecated. Use num2str instead. | |
23 ## | |
24 ## Convert complex number to a string. | |
25 ## @strong{Inputs} | |
26 ## @table @var | |
27 ## @item zz | |
28 ## complex number | |
29 ## @item flg | |
30 ## format flag | |
31 ## 0 (default): -1, 0, 1, 1i, 1 + 0.5i | |
32 ## 1 (for use with zpout): -1, 0, + 1, + 1i, + 1 + 0.5i | |
33 ## @end table | |
34 ## @end deftypefn | |
35 | |
7693
8e5371d47da6
note version when functions were deprecated
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
36 ## Deprecated in version 3.0 |
8e5371d47da6
note version when functions were deprecated
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
37 |
4878 | 38 function retval = com2str (zz, flg) |
39 | |
7696
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
40 persistent warned = false; |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
41 if (! warned) |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
42 warned = true; |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
43 warning ("Octave:deprecated-function", |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
44 ["com2str is obsolete and will be removed from a future\n", |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
45 "version of Octave, please use num2str instead"]); |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
46 endif |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
47 |
4878 | 48 if (nargin < 1 || nargin > 2) |
6046 | 49 print_usage (); |
4878 | 50 endif |
51 if (nargin == 1) | |
52 flg = 0; | |
53 endif | |
54 | |
55 if (! (isscalar (zz) && isscalar (flg))) | |
56 error ("com2str: arguments must be a scalar"); | |
57 endif | |
58 | |
59 if (flg != 0 && flg != 1) | |
60 error ("invalid flg value: %d", flg); | |
61 endif | |
62 | |
63 sgns = "+-"; | |
64 rz = real (zz); | |
65 iz = imag (zz); | |
66 az = abs (zz); | |
67 if (iz == 0) | |
68 ## strictly a real number | |
69 switch (flg) | |
70 case(0) | |
71 retval = num2str (rz); | |
72 case(1) | |
73 retval = [sgns(1+(rz<0)), " ", num2str(abs(rz))]; | |
74 endswitch | |
75 elseif (rz == 0) | |
76 ## strictly an imaginary number | |
77 switch (flg) | |
78 case(0) | |
4898 | 79 retval = [num2str(iz), "i"]; |
4878 | 80 case(1) |
81 retval = [sgns(1+(iz<0)), " ", num2str(abs(iz)), "i"]; | |
82 endswitch | |
83 else | |
84 ## complex number | |
85 ## strictly an imaginary number | |
86 switch (flg) | |
87 case(0) | |
88 retval = [num2str(rz), " ", com2str(i*iz,1)]; | |
89 case(1) | |
90 retval = [sgns(1+(rz<0)), " ", num2str(abs(rz)), " ", com2str(i*iz,1)]; | |
91 endswitch | |
92 endif | |
93 | |
94 endfunction |