7017
|
1 ## Copyright (C) 1996, 2000, 2005, 2006, 2007 Kurt Hornik |
3430
|
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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
3430
|
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 |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
3430
|
18 |
|
19 ## -*- texinfo -*- |
3500
|
20 ## @deftypefn {Functin File} {} dezero (@var{s}) |
3430
|
21 ## Remove trailing blank entries and all zero entries from the string s. |
|
22 ## @end deftypefn |
|
23 |
5428
|
24 ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
3430
|
25 ## Adapted-By: jwe |
|
26 |
|
27 ## Adapted from deblank by A. S. Hodel (a.s.hodel@eng.auburn.edu) |
|
28 ## (the name dezero is a reference to the Fermilab D0 experiment, |
|
29 ## where my sister did her PhD research) |
|
30 |
|
31 function t = dezero (s) |
|
32 |
|
33 ## delete the next line if you're stubbornly going to use dezero. |
7134
|
34 error ("dezero is no longer supported."); |
3430
|
35 |
|
36 if (nargin != 1) |
6046
|
37 print_usage (); |
5443
|
38 elseif (ischar (s)) |
3430
|
39 |
|
40 [nr, nc] = size (s); |
|
41 len = nr * nc; |
|
42 |
|
43 if (len == 0) |
|
44 t = s; |
|
45 else |
|
46 |
|
47 s = reshape (s, 1, len); |
|
48 |
|
49 ## need to remove zeros first, then call deblank |
|
50 s = toascii (s); |
7134
|
51 t = deblank (char (s(find (s != 0)))); |
3430
|
52 endif |
|
53 |
|
54 else |
|
55 error ("dezero: expecting string argument"); |
|
56 endif |
|
57 |
|
58 endfunction |