comparison scripts/control/dezero.m @ 3213:ba1c7cdc6090

[project @ 1998-11-06 16:15:36 by jwe]
author jwe
date Fri, 06 Nov 1998 16:16:31 +0000
parents
children dbcc24961c44
comparison
equal deleted inserted replaced
3212:bf61c443a366 3213:ba1c7cdc6090
1 ## Copyright (C) 1996 Kurt Hornik
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 ## usage: dezero (s)
21 ##
22 ## Remove trailing blank entries and all zero entries from the string s.
23
24 ## Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
25 ## Adapted-By: jwe
26 ## Adapted from deblank by A. S. Hodel (a.s.hodel@eng.auburn.edu)
27 ## (the name dezero is a reference to the Fermilab D0 experiment,
28 ## where my sister did her PhD research)
29 ## $Revision: 1.1.1.1 $
30 ## $Log: dezero.m,v $
31 ## Revision 1.1.1.1 1998/05/19 20:24:13 jwe
32 ##
33 ## Revision 1.3 1997/03/11 14:42:41 scotte
34 ## fixed implicit_str_to_num_ok bug a.s.hodel@eng.auburn.edu
35 ##
36 ## Revision 1.2 1997/03/03 22:52:20 hodel
37 ## fixed problem with conversion to/from numerical value
38 ## a.s.hodel@eng.auburn.edu
39 ##
40 ## Revision 1.1 1997/02/12 11:34:56 hodel
41 ## Initial revision
42 ##
43 ## Revision 1.3 1997/02/07 15:24:35 scotte
44 ## fixed to remove all null characters, then call deblank
45 ##
46
47 function t = dezero (s)
48
49 if (nargin != 1)
50 usage ("dezero (s)");
51 elseif (isstr (s))
52
53 save_val = implicit_str_to_num_ok;
54 implicit_str_to_num_ok = 1;
55
56 #disp("dezero: entry, s=")
57 #s
58 #disp("/dezero")
59
60 [nr, nc] = size (s);
61 len = nr * nc;
62
63 if (len == 0)
64 t = s;
65 else
66
67 #disp("dezero: 1, s=")
68 #s
69 #disp("/dezero")
70
71 s = reshape (s, 1, len);
72
73 #disp("dezero: 2, s=")
74 #s
75 #disp("/dezero")
76
77 # need to remove zeros first, then call deblank
78 s = 1*s;
79 t = deblank(setstr(s(find(s != 0) )));
80 endif
81
82 implicit_str_to_num_ok = save_val;
83
84 else
85 error ("dezero: expecting string argument");
86 endif
87
88 endfunction