detecting 9s in an integer

Rob Mahurin rob at utk.edu
Fri Aug 8 18:05:24 CDT 2008


On Aug 8, 2008, at 6:28 PM, BVBA NuKey Music wrote:
> I'm looking for a fast method using octave to detect whether there is
> a 9 in an integer (decimal representation)
> I need to remove all such integers from a large array filled with  
> integers
>
> i.e. numbers like 19 91 890 should be dropped from the initial array
>
> all help appreciated

It's probably easiest if you use string matching.  Your inital array  
is "z":

octave-3.0.1:54> z = 1:100;
# one number per line
octave-3.0.1:55> sz = num2str(z');
# get row and column index
octave-3.0.1:56> [i,j] = find(sz=="9");
octave-3.0.1:57> z(unique(i)) = []

Cheers,
Rob

-- 
Rob Mahurin
Dept. of Physics & Astronomy
University of Tennessee 	phone: 865 207 2594
Knoxville, TN 37996     	email: rob at utk.edu



More information about the Help-octave mailing list